postgres-bridge icon indicating copy to clipboard operation
postgres-bridge copied to clipboard

jsonb inserted incorrectly when used with slonik

Open random-string opened this issue 1 year ago • 0 comments

The following query inserts a JSON object to a table with a JSONB column.

UPDATE public.property_history
SET attributes = ${sql.jsonb(attributes ?? null)}, status = ${status}
WHERE id = ${id}

When utilizing slonik using

await createPool(pgConnString!, {typeParsers});

it inserts correctly as an object.

However the same query inserts the object as a stringified string when using:

const PgPool = createPostgresBridge(postgres);
await createPool(pgConnString!, {PgPool, typeParsers});

random-string avatar Mar 01 '24 14:03 random-string