This is the snippet of the code :
import SQLite
import Foundation
//---------line 12 -------- ↓
var idCol : Expression<Int64> = Expression("ID") // column variable that represents the ID column
//---------line 60 -------- ↓
func insert(tbl: Table, cols: Expression<Int64> ..., vals: Int64 ...){
do {
...
}
//---------line 101 -------- ↓
func createTable(pk: Expression<Int64>, cols: Expression<Int64> ...) {
// run the create table if the database connection exists and it doesn't exist already.
if let definiteDB = db {
do {
try _ = definiteDB.scalar(tbl.exists)
//print("table exists")
} catch {
do {
//print("table does not exist")
try definiteDB.run(tbl.create() {t in
t.column(pk, primaryKey: .autoincrement)
})
for col in cols {
try definiteDB.run(tbl.addColumn(notNullToNull(expr: col)))
}
} catch let error {
print(error)
}
}
}
}
}
an error occurred on the line 12, 60 and 101 (labelled in the snippet). The error is 'Expression' is ambiguous for type lookup in this context
What can I modify so that the file will build. I am trying to build it on xcode cloud
The iOS 18/macOS 15 SDK now includes a new type called Expression
in Foundation
. This seems to just be a version of Predicate
, except it can output any type, not just Bool
.
This causes a name conflict with the Expression
type declared in SQLite
. You need to write SQLite.Expression
to clarify. Or you can declare a type alias:
typealias SQLExpression = SQLite.Expression