-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Remove enum declaration-order SQL rewriting - #30223
Conversation
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
|
No actionable comments were generated in the recent review. 🎉 i️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe Postgres SQL renderer no longer rewrites enum-backed ChangesPostgres enum ordering
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to PostgreSQL text-backed enums now sort by stored value without injected SQL rewriting, while native enum ordering remains database-managed. The updated behavior and integration expectations are aligned, with no remaining concrete merge-blocking risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
@prisma/orm-extension-arktype-json
npm i https://pkg.pr.new/@prisma/orm-extension-arktype-json@30223
@prisma/orm-extension-middleware-cache
npm i https://pkg.pr.new/@prisma/orm-extension-middleware-cache@30223
@prisma/orm-extension-paradedb
npm i https://pkg.pr.new/@prisma/orm-extension-paradedb@30223
@prisma/orm-extension-pgvector
npm i https://pkg.pr.new/@prisma/orm-extension-pgvector@30223
@prisma/orm-extension-postgis
npm i https://pkg.pr.new/@prisma/orm-extension-postgis@30223
@prisma/orm-extension-supabase
npm i https://pkg.pr.new/@prisma/orm-extension-supabase@30223
@prisma/orm-family-mongo
npm i https://pkg.pr.new/@prisma/orm-family-mongo@30223
@prisma/orm-family-sql
npm i https://pkg.pr.new/@prisma/orm-family-sql@30223
@prisma/orm-framework
npm i https://pkg.pr.new/@prisma/orm-framework@30223
@prisma/orm-mongo
npm i https://pkg.pr.new/@prisma/orm-mongo@30223
@prisma/orm-postgres
npm i https://pkg.pr.new/@prisma/orm-postgres@30223
@prisma/orm-sqlite
npm i https://pkg.pr.new/@prisma/orm-sqlite@30223
@prisma/orm-target-mongo
npm i https://pkg.pr.new/@prisma/orm-target-mongo@30223
@prisma/orm-target-postgres
npm i https://pkg.pr.new/@prisma/orm-target-postgres@30223
@prisma/orm-target-sqlite
npm i https://pkg.pr.new/@prisma/orm-target-sqlite@30223
@prisma/orm-toolchain
npm i https://pkg.pr.new/@prisma/orm-toolchain@30223
commit: 143b1a5
size-limit report 📦
|
Uh oh!
There was an error while loading. Please reload this page.
Linked issue
n/a — small change; no ticket.
At a glance
For a text-backed enum declared as
low, high, medium, this now sorts by stored value:high, low, medium, rather than wrapping the column inarray_position(...).Summary
Enum metadata should not silently change SQL ordering. Remove the declaration-order rewrite and let the database evaluate the original expressions.
Decision
Render
ORDER BYandDISTINCT ONexpressions normally, without consulting enum value sets.Notes for the reviewer
This changes text-backed enum ordering. PostgreSQL native enum types retain PostgreSQL's own declaration-order semantics: this PR introduces no casts or replacement ordering policy. Schema, codecs, and enum member declarations are unchanged.
How it fits together
DISTINCT ON, preserving its expression match withORDER BY.Behavior changes & evidence
DISTINCT ONkeeps the original expression. Implementation:sql-renderer.ts. SQL and PGlite execution evidence:order-by-enum.integration.test.ts.Testing performed
git diff --check: passed.Skill update
No skill update required: query authoring APIs are unchanged, and the adapter now follows the database's ordinary ordering semantics rather than introducing an enum-specific convention.
Checklist
Alternatives considered
ORDER BYunchanged, not impose another sorting policy.Summary by CodeRabbit
ORDER BYandDISTINCT ONqueries retain straightforward column expressions, including when handling NULL values.