lobsters__pushcx@crustaceanson.theshelf.topM to Lobsters - all tags@crustaceanson.theshelf.topEnglish · 23 days ago[databases] Two Kinds of SQL Query Buildersmechanicalrabbit.github.ioexternal-linkmessage-square20linkfedilinkarrow-up10file-text
arrow-up10external-link[databases] Two Kinds of SQL Query Buildersmechanicalrabbit.github.iolobsters__pushcx@crustaceanson.theshelf.topM to Lobsters - all tags@crustaceanson.theshelf.topEnglish · 23 days agomessage-square20linkfedilinkfile-text
minus-squarelobsters__thiht@crustaceanson.theshelf.topMlinkfedilinkarrow-up1·20 days ago convert [‘foo’, ‘bar’, ‘baz’] into … WHERE col IN (‘foo’, ‘bar’, ‘baz’);. I do it with col = ANY($1), and $1is bound as a single value ARRAY[] on the app side (in Go I use pq.Array from lib/pq which does this) ANY is easier to handle than IN in this kind of queries score 1 · canonical
minus-squarelobsters__stephenr@crustaceanson.theshelf.topMlinkfedilinkarrow-up1·20 days agoI guess that’s great if your DB supports an array type, and supports it for ANY(), and the language bindings/driver have support for binding arrays natively. score 1 · canonical
I do it with
col = ANY($1), and $1is bound as a single valueARRAY[]on the app side (in Go I usepq.Arrayfromlib/pqwhich does this)ANYis easier to handle thanINin this kind of queriesscore 1 · canonical
I guess that’s great if your DB supports an array type, and supports it for ANY(), and the language bindings/driver have support for binding arrays natively.
score 1 · canonical