FORGE-85: jsonGet/jsonMerge and countAll/countWhere helpers #708
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!708
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "FORGE-85-json-helpers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part 5 of FORGE-85 (D1 Phase 2, parent FORGE-69). Stacked on #706. No behaviour change.
packages/db/src/json.ts:jsonGet(col, key)(->>; keys limited to identifiers since they're inlined),jsonMerge(col, patch)(coalesce(col,'{}') || patch::jsonb),countAll(),countWhere(cond)(count(*) filter (where …)mapped to number; SQLite supports FILTER).count(*)::intsites (rawdb.executein registry etc.) are left; they'll move with their queries.||is a shallow merge (nested objects replaced, null stored as JSON null). SQLite'sjson_patch(RFC 7396) merges recursively and deletes null keys, so the SQLite port must use onejson_setpath per top-level key.Verification
packages/api/src/__tests__/json-helpers.database.test.ts(6): NULL column, nested replacement, null preservation,->>filter equivalence incl. missing key, key validation, counts equal to the old::intcasts and typed as numbers. Green on PGlite and Postgres 16.🤖 Generated with Claude Code
Preview environment is live: https://pr-708-forgegraph.forgegraf.com
Deployed
ee568decwith the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.ee568decf37bf1ad57f2Preview environment is live: https://pr-708-forgegraph.forgegraf.com
Deployed
7bf1ad57with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.Preview environment is live: https://pr-708-forgegraph.forgegraf.com
Deployed
7bf1ad57with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.7bf1ad57f2568c468ea6568c468ea6556591651e