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

Error using a colon in Select As #22

Closed
AcerLaurinum opened this issue Jun 22, 2020 · 3 comments
Closed

Error using a colon in Select As #22

AcerLaurinum opened this issue Jun 22, 2020 · 3 comments

Comments

@AcerLaurinum
Copy link

Thanks for making such an awesome library! I'm using yesql 4.2.1 and am trying to run a query with a colon in a "Select As" but get a missing value error. For example,

pg.query(named('SELECT :usercount AS "Number of users: ";')({usercount: 5}), (err, result) => {...})

Not sure if this is a bug or I need to be escaping the colon somehow. Thank you!

@pihvi
Copy link
Owner

pihvi commented Jun 24, 2020

Thanks for the compliment!
I can not reproduce this error i.e. can not get missing value error for that query and parameters. Can you provide more details / stack to see what is happening?

@AcerLaurinum
Copy link
Author

My bad, that example does work fine. Here is corrected version that I just tested and can reproduce the error with.

pg.query(named('SELECT :userid::integer as "User:Id"')({userid: 5}), (err, result) => {...})

The error I get is,

Error: Missing value for statement.
Id not provided for statement:
SELECT :userid::integer as "User:Id"
at errorMissingValue (/project/node_modules/yesql/yesql.js:79:9)
at part.replace (/project/node_modules/yesql/yesql.js:46:22)
at String.replace (<anonymous>)
at query.split.map.part (/project/node_modules/yesql/yesql.js:36:23)
at Array.map (<anonymous>)
at /project/node_modules/yesql/yesql.js:32:8
at query (/project/query.js:51:20)
at process._tickCallback (internal/process/next_tick.js:178:7)

@pihvi
Copy link
Owner

pihvi commented Jun 27, 2020

Thanks for the update. There was a bug concerning double quotes with a colon. This is now fixed in latest version (4.1.3). Thanks again for finding this!

@pihvi pihvi closed this as completed Jun 27, 2020
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

2 participants