SQLite.swift icon indicating copy to clipboard operation
SQLite.swift copied to clipboard

can not get column info with join

Open calidion opened this issue 2 years ago • 0 comments

Issues are used to track bugs and feature requests. Need help or have a general question? Ask on Stack Overflow (tag sqlite.swift).

Build Information

  • Include the SQLite.swift version, commit or branch experiencing the issue.
  • Mention Xcode and OS X versions affected.
  • How do do you integrate SQLite.swift in your project?
    • manual
    • CocoaPods
    • Carthage
    • Swift Package manager

General guidelines

  • Be as descriptive as possible.
  • Provide as much information needed to reliably reproduce the issue.
  • Attach screenshots if possible.
  • Better yet: attach GIFs or link to video.
  • Even better: link to a sample project exhibiting the issue.

code:

            let db = try Connection(url)
            let exam_dates = Table("exam_dates")
            let exams = Table("exam")
            let id = Expression<Int64>("id")
            let examId = Expression<Int64>("examId")
            let examIdJoin = Expression<Int64>("exam.id")
            let examName = Expression<String>("exam.name")
            let examDate = Expression<Date>("exam_dates.date")
            let joins = exams.join(exam_dates, on: exam_dates[examId] == exams[id])
            for join in try db.prepare(joins) {
                let nameValue = try join.get(examName);
                print(nameValue)
            }

error message:

No such column `"exam.name"` in columns ["\"exam\".\"categoryId\"", "\"exam\".\"created_at\"", "\"exam\".\"describe\"", "\"exam\".\"id\"", "\"exam\".\"name\"", "\"exam\".\"updated_at\"", "\"exam_dates\".\"date\"", "\"exam_dates\".\"examId\"", "\"exam_dates\".\"id\""]

calidion avatar Feb 17 '24 07:02 calidion