TML-3228: register the SQL built-in attribute specs and source every interpreter call site from the namespace - #30159
Conversation
…lan, trace) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
…mespace Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
…pace Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
…e it reaches the LSP Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
…L namespace Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
…ackage Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
…roject trace Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe SQL authoring package now exposes centralized model and field attribute specifications. Default and relation parsing use symbol-aware factories. SQL family descriptors publish the namespace, and tests cover registration, interpretation, diagnostics, and language-server consumability. ChangesSQL attribute specification surface
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to The PR centralizes SQL attribute specifications and updates consumers to use the shared namespace without any supplied current-head merge-blocking concern. No actionable risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant PSLInterpreter
participant sqlAttributeSpecs
participant sqlFamilyPack
participant LSPConsumabilityTest
PSLInterpreter->>sqlAttributeSpecs: resolve model and field attribute factories
sqlFamilyPack->>sqlAttributeSpecs: publish authoring.attributeSpecs
LSPConsumabilityTest->>sqlFamilyPack: enumerate SQL attributes
LSPConsumabilityTest->>sqlAttributeSpecs: invoke relation and contributed field factories
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
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-paradedb
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mongo
@prisma/orm-postgres
@prisma/orm-sqlite
@prisma/orm-target-mongo
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
size-limit report 📦
|
…cceptance test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Slice 2 of the attribute-registry project (parent TML-3226; builds on TML-3227, #30154). The SQL family now registers its whole built-in attribute surface once, and every consumer — the four interpreter files, the two unknown-attribute checks, and the language server — reads that one registration.
What changed
One namespace, one export.
@internal/sql-contract-pslgainssqlAttributeSpecs(as const satisfies AttributeSpecNamespace): eight model factories (map id unique index check control discriminator base) and six field factories (map id unique noCheck relation default), exposed through a new@internal/sql-contract-psl/attribute-specsentry. The@relationspec moved frompsl-relation-resolution.tsinto the namespace's module so the namespace never imports from a consumer. The individual spec constants and the two@defaultbuilders are no longer exported — a spec is reachable only through the namespace.@defaultis one factory over the uniform ctx. It reads the field's list-ness and the default-function registry from the ctx, and resolves an enum-typed field's member names from the symbol table (topLevel.blocksor the field's namespace scope), replacing the interpreter-sidebuildDefaultSpec/buildEnumDefaultSpecsplit. Both grammars key their positional asvalue, so the factory has a single return type; the enum lowering narrows ontypeof value === 'string'. A memberless enum yields a grammar that rejects every argument.Call sites source from the namespace.
interpreter.ts,psl-field-resolution.ts,psl-column-resolution.ts,psl-relation-resolution.tsreadsqlAttributeSpecs.<level>.<name>(…);symbolTableis threaded to the two@defaultlowering sites (the only factory that consumes ctx).InferAttrtyping at every call site is unchanged and no cast was added or removed.The family registers it.
@internal/family-sqldepends on@internal/sql-contract-psl(moved from dev to prod — family is the last layer in the SQL layer order) and declaresauthoring.attributeSpecson both its pack ref and its control descriptor. The public@prisma/orm-family-sqlexport map gained the matching entry from the build's public-surface sync.Unknown-attribute diagnostics derive from the registry. The hand-maintained
BUILTIN_FIELD_ATTRIBUTE_NAMESset is gone; the field-level check isObject.hasOwn(sqlAttributeSpecs.field, name). The model-attribute loop checksObject.hasOwn(sqlAttributeSpecs.model, name)(or an ADR 236 contribution) before dispatching; the former fall-through diagnostic became anInternalError, since a registered name without an interpreter branch is a programming error. Messages and codes are untouched.LSP proof in final form. The in-package language-server test enumerates a synthetic family field factory through
resolveConfigInputs; the integration test enumerates the real postgres project's full model/field key sets and@relation's named arguments. Both go red if the family stops registering.Why
The project's premise is that the editor can never fall out of step with what the interpreters accept. That only holds when the interpreter and the LSP read the same object — so the namespace is a module constant the interpreter consumes directly (total,
InferAttr-typed access) and the LSP reads throughassembleAttributeSpecs. Deriving the unknown-name checks from the same keys closes the last place a second list could drift.Scope
In: the SQL family only (
sql-contract-psl,family-sql, tests inlanguage-serverandtest/integration). Out: Mongo (TML-3229), block-level attributes (TML-3230), any LSP production change, the registry ADR (project close-out).Decisions taken on the registry-core open items:
resolveConfigInputsstays a deep import (no new import site appeared); the?? new Map()mutation-default fallback stays (the factory receives exactly the registry the old builder did); wrong-level registration is guarded by a test that invokes every factory and assertsspec.level/spec.namematch its subkey.Verification
pnpm --filter @internal/sql-contract-psl test(451),pnpm --filter @internal/language-server test(295), the integration test file (4),pnpm typecheck,pnpm lint:deps,pnpm fixtures:check(byte-clean),pnpm build,pnpm test:packages. Grep gate:rg "ModelSpec\b|FieldSpec\b|buildDefaultSpec|buildEnumDefaultSpec" packages/2-sql/2-authoring/contract-psl/src --glob '!sql-attribute-specs.ts'→ empty. No comment lines added to.tsfiles.Refs: TML-3228
🤖 Generated with Claude Code
https://claude.ai/code/session_01LdeyeSGNsLAJiyKfntYnaA
Summary by CodeRabbit
New Features
@relationarguments.Tests