Format PL/pgSQL ALIAS, RETURN NEXT, and FOR-over-query#9
Conversation
Once the grammar parses these constructs (tree-sitter-postgres #42), the formatter still rendered them incorrectly: - ALIAS declarations dropped their target (`username ALIAS FOR $1` became `username;`). Emit the full `name ALIAS FOR target` form. - RETURN NEXT / RETURN QUERY dropped the NEXT/QUERY keyword. Emit it, including an optional EXECUTE and trailing expression. - A FOR loop over a query dropped the query text after IN because it looked for a non-existent `for_control` node. Take the matched for_* variant up to its nested LOOP keyword instead. Add regression tests. These pass once the dependency is bumped to the tree-sitter-postgres release carrying #42 (1.2.3). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 28 minutes and 27 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
Comment |
Carries the PL/pgSQL grammar support (multi-word types, DEFAULT, bare RETURN NEXT, ALIAS FOR $N) that the formatter changes in this branch depend on. Unblocks the new regression tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Companion to tree-sitter-postgres #42. Once the grammar parses the new PL/pgSQL constructs, the formatter still rendered three of them incorrectly:
username ALIAS FOR $1;becameusername;. Now emits the fullname ALIAS FOR targetform.RETURN NEXT/RETURN QUERYdropped theNEXT/QUERYkeyword (RETURN NEXT;→RETURN;). Now emitted, including optionalEXECUTEand a trailing expression.INbecause the formatter looked for a non-existentfor_controlnode. Now takes the matchedfor_*variant (for_query/for_integer_range/for_cursor/for_dynamic) up to its nestedLOOPkeyword.Adds regression tests covering all three plus multi-word types and
DEFAULT.The new tests parse constructs that only the grammar in gmr/tree-sitter-postgres#42 understands. CI will be red until that PR is merged, released as 1.2.3, and the dependency here is bumped (
tree-sitter-postgres = "1.2.3"). That dep bump is the final step before merge.Verified locally against the #42 grammar (via a path patch): full suite green, all 23 previously-failing production functions format faithfully.
🤖 Generated with Claude Code