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

Missed substitutions from single quotes in comments #9

Open
danfike opened this issue Jul 20, 2017 · 0 comments
Open

Missed substitutions from single quotes in comments #9

danfike opened this issue Jul 20, 2017 · 0 comments

Comments

@danfike
Copy link

danfike commented Jul 20, 2017

When you attempt to do named-placeholders substitutions on SQL strings containing comments with odd numbers of single quote characters, things go awry. I'd guess that, during parsing, the single quote is probably pushing a state on the stack that it shouldn't, since we're in a comment.

Here's an easy example to reproduce

var resolve = require('named-placeholders')();
var sqlq = `
    SELECT :foo AS foo
    UNION ALL
    -- dan's comment
    SELECT :foo AS foo
    UNION ALL
    -- dan's other comment
    SELECT :foo AS foo
`;
var resolvedQuery = resolve(sqlq, {'foo': 'woof'});
console.log(resolvedQuery[0]);

Notice the failed substitution in the second SELECT:

    SELECT ? AS foo
    UNION ALL
    -- dan's comment
    SELECT :foo AS foo
    UNION ALL
    -- dan's other comment
    SELECT ? AS foo

Observed using named-placeholders version 1.1.1

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