-
Notifications
You must be signed in to change notification settings - Fork 9
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
parameters #24
Comments
Yes, it is probably possible to have a preprocessor that scans through the statement, replacing But if you look at brianc/node-postgres#268, there are plenty of reasons not to want something like that – opting instead for doing this on a higher level; for example, a query builder could provide such an interface. |
oh. well that makes sense. thanks for sharing that link! maybe we could whip up some sugar for named params? would you rather that be in a separate repo/package, or would you be interested for some kind of |
i just read that, and thought about tagged template literals at the same time — and got a nerd-boner! |
It might be possible to implement this sugar using a tokenizer only and not have to actually parse the query. I wouldn't mind having a simple desugaring function in the code – the functionality is nice to have for sure. |
i'm thinking something along these lines ought be possible! const result = await query`SELECT * FROM table WHERE column = ${value}` how do you fancy? |
That looks good. People understand the escaping of those literals because of the tagged literal syntax. And it's far better than |
i'll look into putting together a pull request for you, to add a |
from the readme,
do the parameters have to be numbered? i'd much prefer to use names, as i'm familiar with using parameter placeholders like
SELECT * FROM whatever WHERE :lol = 5
or something like that, right?i'm just really hoping i don't have to worry about how things are ordered, i'm an options-object kind of guy
The text was updated successfully, but these errors were encountered: