stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.72k stars 1.57k forks source link

can not get column info with join #1240

Open calidion opened 8 months ago

calidion commented 8 months ago

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

General guidelines

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\""]