`sql().toParams()` generating wrong parameter bindings
See original GitHub issueFirst off, thanks for a great solution! I just adopted this module for an ORM I’ve been working on and so far everything is great. I found a small bug though when writing tests (with version 2.0.3):
const sql = require('sql-bricks');
const query = sql
.select()
.from('foo')
.where(
sql.and(
sql('a like $1',1),
sql('b <> $2', 1)
)
);
console.log(query.toString());
// => SELECT * FROM foo WHERE a like 1 AND b <> 1 // good
console.log(query.toParams());
// { text: 'SELECT * FROM foo WHERE a like $1 AND b <> $3', values: [ 1, 1 ] }
// here, `text` has wrong bindings
Is this a known issue? It’s not a biggie because I can work around it by using (EDIT: I spoke too soon, it doesn’t seem to work either), but I thought it would be nice to report this. Also more than happy to submit a PR if I can help in any way.?
as the placeholder
Thanks!
PS: Might be related to https://github.com/CSNW/sql-bricks/issues/96
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
DatabaseError: Incorrect number of bindings supplied
when I run crime_neighbor("cbd") , I get the following error: DatabaseError: Execution failed on sql 'SELECT * FROM crime WHERE NEIGHBORHOOD_ID ...
Read more >got an error while creating bind variables using sql database.
I'd take a guess and say SQL Server doesn't like Oracle binding style parametes in query, of the form colon variable name ie...
Read more >Invalid parameter binding(s) error wiith SQL request
Hello, I'm trying to change email subject sent for one project and I don't know where is the error. The command is :...
Read more >SQL Bind Variables/Parameters in Databases
There is nothing bad about writing values directly into ad-hoc statements; there are, however, two good reasons to use bind parameters in programs:...
Read more >Anorm, simple SQL data access - GitHub Pages
To execute an update, you can use executeUpdate() , which returns the ... Anorm also provides utility to generate parameter conversions for case...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@prust thanks. I’m okay to proceed however you see fit and btw I hope it didn’t come across as me urging you to get things done - was not at all my intention. I also don’t have as much time as is ideal but I’ll try to pick something up, most likely the 5th todo: “reduce the variety of ways things can be called”.
Going back to this issue though, I’ve found another small bug:
I’m using
toParams
so this is not really a problem, but I thought I’d also point it out. Will the fixes to the templating code also address this?@joelmukuthu: I created separate checkboxes for each task in #92 and checked off the one that’s complete (implemented in #100, landed in
master
and tagged asv3.0.0-beta.1
). You’re welcome to try your hand at any of them, or (perhaps a better first step) to pick one and create an Issue for it and start fleshing out the details by analyzing the current implementation and outlining in more detail how it could be implemented or asking questions about different possible implementation choices.That said, you’re also welcome to wait until I’ve taken a first pass and figured things out in more detail, or – if I get part way into implementing something & document how far I’ve gotten, you may want to carry the rock forward on that particular task. I’m planning on pecking away at this over the coming months, but my time on this project is limited, so any assistance would be much appreciated.