Open sidorares opened 10 years ago
I saw it and I think people would like it. I personally like namedPlaceholders and the flag better. I think a must-have feature for it would be the ability to turn to on on a per-query basis (and a per-format-call basis), right? It would make it much easier to start using on a very large code base, since you would have to check all the queries for :blah contents.
I'm not firm on any arguments, but if like to hear your comments on it :) I'm in general +1, as it would, at the basic level, make using the same value multiple times in the query much simpler.
Also, is there an equivalent for ?? in the named placeholders?
I'll rename it to namedPlaceholders
I need to think about ?? in query and differences in parameters semantics between query & execute
It's already possible to change any flag per query by accessing connection.config
, but yes, maybe we need more explicit api
+1 for named param support.
@sidorares - Does the "possible to change any flag per query" apply to pools as well?
We're exporting a pool of connections with:
var pool = mysql.createPool(config.database.main);
exports.con = pool;
Would I have to export another pool where flags can be changed?
Sorry for the change of direction :P
@adrianblynch each connection from a pool will simply inherit options from the pool itself. So if namedParameters
is off in the pool, it'll be off for each connection, though when this is added, you can simply enable named parameters on a query-by-query basis anyway
Cheers @dougwilson :+1:
Are named params coming soon?
Yep!
Right now you still have to use the named-placeholders
libraries in your own code. Example usage is at https://www.npmjs.com/package/named-placeholders#usage
I'm thinking to add named parameters support to mysql2 ( https://github.com/sidorares/node-mysql2/pull/125 ), by default hidden behind config flag. Would you like to see similar functionality here? What do you think of api?