Feature request: Named parameters in prepared statements / parameterized queries
See original GitHub issueI would like it very much if we could name parameters in queries, instead of the current $1, $2, $3… nonsense. For example:
client.query("INSERT INTO beatles(name, height, birthday) values($1, $2, $3)", ['John', 68, new Date(1944, 10, 13)]);
would become:
client.query("INSERT INTO beatles(name, height, birthday) values(:name, :height, :birthday)", {
name: 'John',
height: 68,
birthday: new Date(1944, 10, 13)
});
It would allow for much cleaner code in more complex cases.
Issue Analytics
- State:
- Created 11 years ago
- Reactions:37
- Comments:19 (12 by maintainers)
Top Results From Across the Web
Using parameterized queries - Amazon Athena
Prepared statements require two separate SQL statements: PREPARE and EXECUTE . First, you define the parameters in the PREPARE statement. Then, you run...
Read more >Named Parameters for PreparedStatement - InfoWorld
A mapping is kept between parameter names and their indices. This mapping is referred to when the parameters are injected. The two classes...
Read more >Using Prepared Statements - JDBC Basics - Oracle Help Center
This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how...
Read more >Named parameters in JDBC [duplicate] - java - Stack Overflow
Reuse a parameter in a PreparedStatement? 3 · Sql query with bind variables execution in Jdbc · 5 · How to use named...
Read more >Query Parameterization - OWASP Cheat Sheet Series
SQL Injection is best prevented through the use of parameterized queries. ... db.prepare "INSERT INTO users (name, age, gender) VALUES (?, ? ,?)...
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
I’ve followed brianc’s advice and put together a monkeypatching solution that should work with node-postgres and node-postgres-pure alike.
https://github.com/bwestergard/node-postgres-named
Here’s another “cleaner” way to solve this with a library. No need for monkeypatching: