-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conflict with pg-promise #91
Comments
@kay999: Yes, I'm surprised no one has mentioned this before. I prefer named parameters over numbered parameters as well; I'd like to add support, I'll see what impact that they will have on the API and the internals.
Yes, we should expose the |
@kay999: I wrote a test to demonstrate how I think the API should work with support for named parameters: it('should supported named placeholders', function() {
var values = {'first_name': 'Fred', 'last_name': 'Flintstone'};
var result = insert('user', values).toParams({'placeholder': '$[name]'});
assert.equal(result.text, 'INSERT INTO "user" (first_name, last_name) VALUES ($[first_name], $[last_name])');
assert.deepEqual(result.values, {'first_name': 'Fred', 'last_name': 'Flintstone'});
}); However, in trying to implement this I realized that it requires a fairly deep change (using I have a feeling that this kind of change would need to happen as part of a deep refactoring along with some other deep changes aimed at simplifying the implementation (in part by making the inputs less flexible). In the meantime, does it work to use |
I created a small pull request (#93) which allows changing the defaults. Works for me. |
Ok, thank you, everything works now by using |
I'm using sql-bricks together with pg-promise (in fact I'm using sql-bricks-postgres, but the issue is in sql-bricks) which supports named parameters via a $[name]-syntax. So I tried using
sql('$[name]')
to use this pattern for example in where-expressions.But this doesn't work because sql-bricks replaces the "$" with "$1". Now I found out that I can use
toString({ placeholder:'?%d' })
which makes everything works, but it feels odd and took me some time to discover. And It's annoying to replace alltoString( )
withtoString({ placeholder:'?%d' })
Is there a better way to solve this? Maybe with some global config which stops sql-bricks to replace '$' with $i++ altogether? Using autmatic numbering is quite risky anyway.
The text was updated successfully, but these errors were encountered: