Hello,
I have the following:
var passedDetails:String! (it gets a value before the filtering)
let additivesTable = Table("Additives")
let keyColumn = Expression<String>("key")
When I try to filter:
let valueAdditive = additivesTable.filter(keyColumn == passedDetails)
I'm getting this error: Binary operator '==' cannot be applied to operands of type 'Expression<String>' and 'String!'
The same thing worked perfectly on Swift 1.2. Any ideas?
Hm, this may be a bug in Swift 2 type resolution. I'll see if I can repro and file a bug with Apple if need be. In the meantime, does the problem go away if you call passedDetails!? Is there a way to refactor this code so that you don't have to use an implicitly-wrapped optional?
Nope, the error appears even if its "passedDetails!".
It also appears if I simply add a string instead of the variable.
Oh, stupid me.
I forgot to add "import SQLite" into the class and that's why the error occurs. Geez...
Is it fixed? I am trying like this
var index = String
let Index = Expression<String?>("Index")
for row in DataManager.con.prepare(table).filter(index == Index){
}
gives me compile error like below.
/Common Files/GitHiub/vesseltracker-xcode/vesseltracker/vesseltracker/Model/CrewList.swift:155:64: Cannot convert value of type 'Expression<Bool?>' (aka 'Expression<Optional<Bool>>') to expected argument type '@noescape (Row) throws -> Bool'
Am I doing anything wrong?
@vineethvijayan The filter method needs to be called on the table, not the prepared statement. Did you find an error in the docs that had you code it this way?
Yes my mistake @stephencelis Sorry about that
@stephencelis
How about this case? Did I make something wrong?

Most helpful comment
Oh, stupid me.
I forgot to add "import SQLite" into the class and that's why the error occurs. Geez...