The SQLite.swift documentation for filtered queries gives this example:
users.filter(email.like("%@mac.com"))
// SELECT * FROM "users" WHERE ("email" LIKE '%@mac.com')
Since I want to search the database based on user input, I guess I could do the following:
let stringPrefix = userInput + "%"
users.filter(email.like(stringPrefix))
// SELECT * FROM "users" WHERE ("email" LIKE 'johndoe%')
Am I going about this the right way? With other SQLite environments in the past I have used variable binding with ?
to avoid SQL injection. Is this done behind the scenes with SQLite.swift? I didn't see any information in the documentation except for a little bit about binding in the Executing Arbitrary SQL section.