When using a WITH query, the column resolution function columnNamesForQuery says no such table, despite the fact that the exact same expression works if converted to raw SQL first.
Repro example:
let tempTable = Table("recent_matches")
let q = tempTable.with(tempTable, as: searchRanking.table.match("cat"))
print(q.expression.description)
do {
// Works
let array = try Array(try db.prepareRowIterator(q.expression.description))
// Does not work
//let array = try Array(try db.prepareRowIterator(q))
} catch {
print("VONK", error)
}
Logs:
WITH "recent_matches" AS (SELECT * FROM "searchRanking" WHERE ("searchRanking" MATCH 'cat')) SELECT * FROM "recent_matches"no such table: recent_matches (code: 1)
It looks like in cases with WITH clauses, columnNamesForQuery behaves incorrectly, while columnNameMap powered by sqlite3_column_name works fine.
When using a WITH query, the column resolution function
columnNamesForQuery
saysno such table
, despite the fact that the exact same expression works if converted to raw SQL first.Repro example:
Logs:
WITH "recent_matches" AS (SELECT * FROM "searchRanking" WHERE ("searchRanking" MATCH 'cat')) SELECT * FROM "recent_matches"
no such table: recent_matches (code: 1)
It looks like in cases with
WITH
clauses,columnNamesForQuery
behaves incorrectly, whilecolumnNameMap
powered bysqlite3_column_name
works fine.