How to call query_with_bindings() with quotes in the WHERE clause #222
-
|
Hello! I'm running into an issue where The query succeeds, but I get a warning log in console implying that the binding failed. I can run the same query against the database in DBViewer (substituting the question mark for some string). If I remove the quotes, the variable binding work as expected. Is there some secret sauce I'm missing? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Hello @iamrequest, What warning log do you get in the console? |
Beta Was this translation helpful? Give feedback.
-
|
You can't put bindings inside of quotes in SQLite -> That is why it is not working in your case. Here are your possibilities: var query := "SELECT * FROM songs WHERE name LIKE '%' || ? || '%';"
var params = ["a"]
_db.query_with_bindings(query, params)
print(_db.query_result)or: var query := "SELECT * FROM songs WHERE name LIKE ?;"
var params = ["%a%"]
_db.query_with_bindings(query, params)
print(_db.query_result) |
Beta Was this translation helpful? Give feedback.
-
|
I see, I didn't realize that was an issue. Thanks! 😁 |
Beta Was this translation helpful? Give feedback.
You can't put bindings inside of quotes in SQLite -> That is why it is not working in your case.
Here are your possibilities:
or: