pg
pg copied to clipboard
incorrect query marshalling the nil []string to null
create table settings
(
aspects jsonb default '[]'::jsonb,
);
var a []string
Db.Query( &ss, `select * from settings where aspects @> coalesce(?, '[]'::jsonb)`, a)
the query msg will become:
select * from settings where aspects @> coalesce('null', '[]'::jsonb)
not what I expect:
select * from settings where aspects @> coalesce(null, '[]'::jsonb)
only the literal nil work:
var a []string
Db.Query( &ss, `select * from settings where aspects @> coalesce(?, '[]'::jsonb)`, nil)
results:
select * from settings where aspects @> coalesce(null, '[]'::jsonb)