4 ms·
Thanks! I'm curious - What's the reason you don't like the tagged template literal? It's those that give you implicit safe parameters and let's you avoid doing
by porsager 5y ago
Thanks!
I'm curious - What's the reason you don't like the tagged template literal? It's those that give you implicit safe parameters and let's you avoid doing parameter counting when writing queries.
- megous 5y agoI don't like the sql() helpers part, and that they try to guess whether I want a helper for insert or update, based on some regexes and that helpers for different things all are sql(something) while doing very different things. https://github.com/porsager/postgres/blob/master/lib/index.js#L458 https://github.com/porsager/postgres/blob/master/lib/index.j... I also tend to compose queries out of smaller static parts dynamically, and tagged syntax does seem to make that hard. Patterns like: let params = {}; let conds = ['TRUE'] if (some_user_input) { conds.push('a = $test'); params.test = some_user_input; } db.query(` SELECT cols, ... FROM xxx WHERE abc AND ${conds.join(' AND ')} `, params); Not having a way to compose tagged literals and not having named parameters, only $1 just made it hard to port any of my existing projects based on pg-promise to your library. I use named parameters, so I don't do parameter counting. Connector does that for me, when rewriting the parameters to native postgresql syntax.
- porsager 5y agoThat makes perfect sense. Thanks a lot for the feedback.
- megous 5y agoAnyway, I'm a fan of suckless (https://suckless.org/ https://suckless.org/) and I try to use minimum set of dependencies (incl. transitive dependencies) in my node projects too. I like your project a lot from this perspective and that given its small size and lack of dependencies, it's also easily malleable to different needs, than the ones you anticipated.