Describe sort-argument misuse in index field lists - #30303
Sanjays2402 wants to merge 1 commit into
Conversation
Parsing @@index([created_at(sort: Desc)]) failed with the cryptic 'Expected a field name' because fieldRef only accepts bare identifiers while a sort annotation parses as a FunctionCallAst. Detect that shape and explain that field lists take bare field names without arguments. Fixes prisma#30270
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe parser now gives a specific diagnostic when a field list contains a function-call argument. Tests cover direct field-reference parsing and ChangesField-list diagnostic clarification
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change clarifies unsupported field-list diagnostics and adds matching parser and interpreter coverage, with no established merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Fixes #30270.
@@index([created_at(sort: Desc)])failed during contract resolution with the crypticPSL_INVALID_ATTRIBUTE_SYNTAX/ "Expected a field name". The field-list parser (fieldRef) only accepts bareIdentifierAsttokens, while a sort annotation parses as aFunctionCallAst— so users got a message that described the parser's expectation rather than their mistake.parseFieldNamenow detects the function-call shape and reports the actual problem:Expected a bare field name, but found "created_at(...)" — field lists do not accept arguments, so (sort: Asc/Desc) is not supported here.Anything that isn't a single-segment call keeps the original "Expected a field name" diagnostic. (Full sort-direction support would need index-IR/DDL changes; the issue accepts the descriptive diagnostic.)Testing: new unit test in
psl-parserfails before the fix (message lacks any mention of sort) and passes after; new end-to-end test incontract-pslreproduces the issue's exact@@index([createdAt(sort: Desc)])schema and asserts the diagnostic names sort instead of the cryptic message. Full suites pass: psl-parser 703/703, contract-psl 463/463;tsc --noEmitandbiome checkclean on all touched files.Summary by CodeRabbit
id(sort: Desc)and index field lists with sort annotations now report the appropriate syntax error instead of a generic field-name error.