PRS-215: Emit jsonb_build_object with 50-pair chunking in Postgres adapter#999
Open
prisma-gremlin[bot] wants to merge 1 commit into
Open
PRS-215: Emit jsonb_build_object with 50-pair chunking in Postgres adapter#999prisma-gremlin[bot] wants to merge 1 commit into
prisma-gremlin[bot] wants to merge 1 commit into
Conversation
…apter renderJsonObjectExpr now emits jsonb_build_object instead of json_build_object, batching entries at 50 key/value pairs per call (100 args, Postgres' function-call argument cap) and merging per-chunk objects with the JSONB || concatenation operator. Objects of 50 or fewer pairs render a single call with no concatenation. Updates the adapter README prose and the Query Lanes subsystem doc, fixes the pgvector rich-adapter assertion that still expected json_build_object, and adds adapter tests covering the <=50 and >50-field chunking cases. Refs: PRS-215, prisma-engines#4555 Signed-off-by: Gremlin <gremlin[bot]@users.noreply.github.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe PostgreSQL SQL renderer now uses ChangesPostgreSQL JSONB rendering
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
size-limit report 📦
|
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/config-loader
@prisma-next/emitter
@prisma-next/language-server
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Alexey Orlenko · Slack thread
What & why
The Postgres adapter's
renderJsonObjectExprpreviously emitted a singlejson_build_object(...)call with all key/value pairs inline. PostgreSQL caps function-call arguments at 100, so an object with more than 50 key/value pairs (100 args) would error at runtime. This switches the render path tojsonb_build_objectand batches entries 50 key/value pairs per call, merging the per-chunk objects with the JSONB||concatenation operator. JSONB is required because||concatenation is only defined onjsonb, not plainjson.For 50 or fewer pairs, a single
jsonb_build_object(...)call is emitted with no||— same shape as before, justjsonbinstead ofjson.Changes
packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts—renderJsonObjectExprnow rendersjsonb_build_object, chunking entries into batches of 50 pairs and joining batches with||.packages/3-targets/6-adapters/postgres/README.md— prose updated fromjson_build_objecttojsonb_build_object, plus a note describing the chunking behavior and the 100-argument cap rationale.packages/3-targets/6-adapters/postgres/test/adapter.test.ts— fixed an existing assertion that still expectedjson_build_object; added two tests covering the ≤50-field case (single call, no||) and the >50-field case (multiple calls merged with||, each holding ≤50 key/value pairs).packages/3-extensions/pgvector/test/rich-adapter.test.ts— fixed the rich-adapter assertion that still expectedjson_build_object.docs/architecture docs/subsystems/3. Query Lanes.md— render-path doc updated to reflectjsonb_build_objectand the chunking behavior (doc-maintenance rule).Prior art & tracking
Mirrors the approach from prisma-engines#4555. Tracks Linear issue PRS-215.
Created by Mohawk
Summary by CodeRabbit
New Features
Documentation