Cannot invoke 'filter' with an argument list of type '(Bool)'
I have this:
keywords.filter(!SQLite.contains(foundKeywords, Expression<String>("Word"))
and Swift 1.2 report: Error: Cannot invoke 'filter' with an argument list of type '(Bool)' but only when compiled with -O (release)
I want to build "NOT IN" clause. What I'm doing wrong?
@krzyzanowskim Huh. That looks right. I'm assuming there's a compiler bug in Swift 1.2, but hopefully we can find a workaround. What if you move the filter above?
let keywordFilter = !SQLite.contains(foundKeywords, Expression<String>("Word")
keywords.filter(keywordFilter)
that did not help, I had to workaround usage of "!" function. Since wrap() is private, I did this:
let containsExpression = SQLite.contains(foundKeywords, DBKeywords.Word)
let notContainsExpression:Expression<Bool> = Expression(literal: "NOT (\(containsExpression.SQL))", containsExpression.bindings)
That should be an OK workaround for now. I'll see if I can find a better one. This is likely fixed in 2.0, though.
I am facing this issue even on swift 2.1.1
do {
let row = placesTable.filter( placeID == 1)
if try app.sharedInstance.database.run(row.delete()) > 0 {
print("row deleted")
} else {
print("row not found")
}
} catch {
print("delete failed: \(error)")
}
This line shows a compile error
let row = placesTable.filter( placeID == 1)
Cannot invoke 'filter' with an argument list of type '(Bool)'
I came across exactly the same problem as bijugv using xCode 10.1, swift 4.2. The line:
let query = clients.where(clientKey == 1)
Generates the error message Cannot invoke 'filter' with an argument list of type '(Bool)'.
Which was very puzzling as similar code in other parts of the app worked fine.
It appears to be something weird with the compiler. After a frustrating hour or so I created another function with the exact same code and all was well!
Looks like this was caused by some Swift compatibility change?