Repository navigation
TML-3324: Parse view bodies as model fields only in Prisma 7 and Prisma 6 schemas - #30507
Conversation
…ma 6 schemas A PSL contract source declares parserOptions. The Prisma 7 and Prisma 6 sources set viewBodyAsModelFields; contract format passes the source's options to the formatter. By default a view body parses as key = value entries. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ests pin what users see Addresses the code review: the language server reads parserOptions from the config and passes them when it diagnoses and formats; PslParseOptions is renamed PslParserOptions; the config loader rejects an unknown parser option; the Prisma 8 sources, the formatter and a Prisma 7 format journey have tests for a view block; ADR 252 and the config README describe the rule. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: prisma/orm/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughPSL sources can declare parser options that select how view-body lines are parsed. The parser, formatter, CLI, and language server pass these options through. Prisma 6 and Prisma 7 sources declare the ChangesConfigurable PSL view parsing
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant resolveConfigInputs
participant Project
participant ProjectArtifacts
participant DocumentSnapshot
participant parse
resolveConfigInputs->>Project: returns parserOptions
Project->>ProjectArtifacts: passes parserOptions
ProjectArtifacts->>DocumentSnapshot: creates configured snapshot
DocumentSnapshot->>parse: parses text with parserOptions
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains; files should be formatted using the grammar configured for their source. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 5 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 28.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 32 files. (3 skipped: 3 unsupported.) ✨ 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 📦
|
…-view-body-parser-option Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> # Conflicts: # packages/1-framework/3-tooling/language-server/src/config-resolution.ts # packages/1-framework/3-tooling/language-server/src/document-diagnostics.ts # packages/1-framework/3-tooling/language-server/src/pipeline.ts # packages/1-framework/3-tooling/language-server/src/project-artifacts.ts # packages/1-framework/3-tooling/language-server/test/server.test.ts
…er stored snapshot Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… the artifacts load into project.ts Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…-body flag The parser option is grammar: 'prisma-7' | 'prisma-8', default prisma-8. In the prisma-7 grammar a view body parses as model fields. The Prisma 7 and Prisma 6 sources declare prisma-7, since Prisma 6 schemas use the same grammar. The parser is the authority on its own grammar, so its grammar names may name the Prisma version; the vocabulary rule records that exception. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…cabulary check Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…the grammar option; tests cover an explicit prisma-8 Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…rint budget Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
This brings in seven main commits: the rc.14 release, Mongo values through their field's codecs (#30519), `sql` as the tag of sql/expression (#30534), view bodies parsed as fields only in Prisma 7 and 6 schemas (#30507), and three docs and CI changes. Both sides' rules hold after the merge. - Mongo codecs: main's encode checks and this branch's decodeJson readers are combined, and the int32 bounds use INT32_RANGE. - One test codec from main now has the decodeJson that mongoCodec requires. - contract-psl: main's tag reading and sql/expression default replace the lowering entry. This branch's stored-value reader, InternalError rethrows, list-column and value-object default checks, and CodecLookupWithDescriptors are kept. - A value-object default of the wrong shape uses main's renamed code, PSL_VALUE_TYPE_INCOMPATIBLE. A Uuid default the text-to-uuid cast refuses is PSL_INVALID_LITERAL, like any other cast refusal. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Linked issue
Refs: TML-3324
Summary
A Prisma 7 schema can declare a view:
The Prisma 7 source refuses it with one error,
PSL.PRISMA7_VIEW_UNSUPPORTED. To report one error, the parser has to read the lines of theviewblock as model fields. Until now the shared parser did that in every file, Prisma 8 files included, whereviewis not part of the language.Decision: the parser names the grammar versions it reads. A PSL contract source declares which one its files are written in, through
parserOptions.grammar:prisma-8(the default) orprisma-7. In theprisma-7grammar aviewbody parses as model fields.Prisma 6 schemas use the same grammar, so
prisma6Contractdeclaresprisma-7too. Aprisma-6value gets added only if a Prisma 6 grammar difference turns up.Every tool that parses a source's files passes the source's options to the parser:
parsecalls. Their view errors and spans are unchanged.prisma contract formatpassessource.parserOptionstoformat(), so it still formats a Prisma 7 schema that contains a view with attributed fields.parserOptions. It reports a grammar it does not know, and an option key it does not know.In a Prisma 8 file, a
viewbody now parses askey = valueentries, like any other block the parser does not know. Two things change for a user who writes one:PSL_INVALID_EXTENSION_BLOCK_MEMBER), reported before the block errorPSL_UNSUPPORTED_TOP_LEVEL_BLOCK, which is unchanged.contract formatwritesid IntasidandInton separate lines, as it does in any block it does not know.PslGrammarandPslParserOptionslive in@internal/configbesidePslContractSourceProvider, which declares them. The parser already depends on that package. The framework vocabulary rule forbids names of Prisma versions before 8 in the framework; it now records one exception, the parser's own grammar names, and the three sites carry a suppression with that reason.ADR 252, the config and parser READMEs, the two source READMEs and the project spec describe the grammar option.
Testing performed
parse-view-body.test.tsand the formatter tests cover aviewbody in theprisma-7grammar and in the default grammar.grammar: 'prisma-7'. The existing view fixtures still report the same codes and spans.viewblock and asserts the full list of diagnostics.contract format: a unit test uses a source that declares the grammar. A step in the Prisma 7 source journey formats a real Prisma 7 project with a view; it fails when the source does not declare the grammar.parserOptions, and a misspelled option key.lint,lint:deps,lint:throws,lint:framework-vocabulary,check:upgrade-coverageandtypecheck.Skill update
n/a. Users do not write
parserOptions; the Prisma 7 and Prisma 6 sources set it. Those sources report the same view errors as before, and aviewblock in a Prisma 8 file is still refused.Checklist
git commit -s) per the DCO.TML-NNNN: <sentence-case title>form.Notes for the reviewer
One case gets worse and is filed as TML-3370. A Prisma 8 source whose input pattern also matches an unmarked Prisma 7 file skips that file, but
contract formatstill formats it with the Prisma 8 grammar. A view in that file is now refused or split. The fix needs the source to declare which files it reads, which is a separate design question.Alternatives considered:
viewBodyAsModelFields, instead of a grammar version. Rejected: the flag has no meaning on its own. It exists only because the Prisma 7 grammar readsviewbodies that way, and nobody would set it on a Prisma 8 source. Naming the grammar says why, and absorbs any further Prisma 7 grammar difference without a second flag.datasourceblock or a missing// use prisma-8line. Rejected: every tool would repeat the detection, and a guess can be wrong.viewkeyword.Agent: shaka-90
Summary by CodeRabbit
viewbodies as model fields.viewbodies.