Skip to content
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

Parameterized query not working with IN operator #57

Open
cmallen47 opened this issue Jul 7, 2016 · 0 comments
Open

Parameterized query not working with IN operator #57

cmallen47 opened this issue Jul 7, 2016 · 0 comments

Comments

@cmallen47
Copy link

I am attempting to parameterize the following query:
SELECT test_name FROM web_test_data WHERE test_id IN ('f_0001', 'f_0002', 'f_0003');

My thought is that I can use a variable @tests to plug in where my id values are specified by the IN operator. Here is my code:

var SQL = require('seriate');
var ids = "'f_0001', 'f_0002', 'f_0003'";

SQL.setDefault(config);
SQL.execute({
query: "SELECT test_name FROM web_test_data WHERE test_id IN (@tests)",
params: {
tests: {
type: SQL.NCHAR,
val: ids
}
}
})
.then(function(results) {
console.log('running tests ->', results);
}, function(err) {
console.log("An error occurred when attempting to query for running tests", err);
})

My query runs without errors but I get an empty result set. This is not expected. However, when I replace @tests with 'f_0001', 'f_0002', 'f_0003' I get the result set I expect. I'm wondering if the double quotes wrapping my inner id values when defining var ids is causing the problem?

Does Seriate support parameterized queries in this way using the IN operator or did I make some mistake that I'm overlooking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant