-
-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
namedPlaceholders with IN clause #196
Comments
Is there a way to query an in clause? When I try to run something like the above statement it only runs the first key in the group. I think there is a bug that only uses the first item in the array even if its a string |
There is currently 'arrayToList' in SqlString, but it seems that it does not work for example like @steven10172 - I'd like to keep named placeholders semantics close to unnamed, so Ideally we need to make unnamed |
@steven10172 for binary protocol ( prepared statements ) one placeholder always represent one prepared statement parameter. // text protocol, works without helper:
db.query("select * from mysql.user where Host in (:hosts)", { hosts: ['localhost', '127.0.0.1'] }, ...);
// binary protocol: hosts is one single parameter, serialised as `['localhost', '127.0.0.1'].toString()`
db.execute("select * from mysql.user where Host in (:hosts)", { hosts: ['localhost', '127.0.0.1'] }, ...);
// result is execute "select * from mysql.user where Host in (?)" with "localhost,127.0.0.1" as parameter
// probably not what you expect I'd probably suggest var hosts = ['localhost', '127.0.0.1'];
db.execute("select * from mysql.user where Host in (" + hosts.map( () =>'?' )+ ")", hosts, cb); |
Anything new regarding this issue? |
It would be nice to have namedPlaceholders convert arrays of data into an IN clause.
I would like the following to be possible:
It should execute to the following:
The text was updated successfully, but these errors were encountered: