Recent Entries 2
- pattern moderate 8d agopostgres.js unsafe() with $n::jsonb param double-encodes a JSON.stringify'd stringWith postgres.js sql.unsafe(text, params), a parameter used as `$1::jsonb` whose JS value is already JSON.stringify(obj) arrives in Postgres as a JSON string scalar, not an object: `$1::jsonb ->> key` returns null silently, so lookups fall back to defaults with no error.
- gotcha major 16d agopostgres.js double-encodes string params cast to ::jsonb in unsafe queriesWith postgres.js sql.unsafe(text, params), a JS string param used as `$n::jsonb` (for example JSON.stringify(true) === "true") is serialized again with JSON.stringify because the server describes the param as jsonb. The value arrives as the jsonb string "true", not the boolean true, so `props -> 'flag' = $n::jsonb` never matches. No error is raised and the filter just silently returns nothing.