ReviewOS

stacks/bun-query-builder

whereJsonContains hardcodes Postgres '@>' for every dialect (ignores dialect + jsonContainsMode)

#1026
Closed glennmichael123 opened this 22 days ago · 0 comments
22 days ago

Summary

whereJsonContains always emits column @> $n. @> is Postgres-only — it's a syntax error on SQLite/MySQL — and the method ignores the existing config.sql.jsonContainsMode toggle that exists for exactly this. The adjacent whereJsonPath already branches per dialect, so this is inconsistent.

Evidence (repro, sqlite)

selectFrom('posts').whereJsonContains('meta', {a:1}).toSQL()  ->  ... WHERE meta @> ?

Location

src/client.ts:~3836.

Suggested fix

Branch on config.dialect: JSON_CONTAINS(col, ?) (MySQL), json_extract/EXISTS (SQLite), @> (Postgres), honoring config.sql.jsonContainsMode.

Severity: high (breaks the cross-dialect promise). Found via internal code audit.

Sign in to comment on this issue.