Fix Postgres default parsing for pg_catalog.nextval(...)#5802
Fix Postgres default parsing for pg_catalog.nextval(...)#5802Lukasdoe wants to merge 1 commit intoprisma:mainfrom
pg_catalog.nextval(...)#5802Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughPostgres integer default parsing updated to recognize Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the Postgres default-value parser in sql-schema-describer to recognize schema-qualified nextval() calls (e.g. pg_catalog.nextval(...)) so autoincrement/sequence defaults are correctly detected during introspection.
Changes:
- Extend integer default parsing to accept
*.nextval(...)in addition tonextval(...). - Add a regression test covering
pg_catalog.nextval('...')sequence defaults.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@schema-engine/sql-schema-describer/src/postgres/default.rs`:
- Around line 312-327: The qualified-name branch currently accepts any
"<schema>.nextval(...)" by only checking the trailing identifier; change the
logic in the is_nextval computation so that when a Token::Dot is present you
first treat the existing identifier s as the schema and only accept the match if
s.eq_ignore_ascii_case("pg_catalog") AND the following identifier equals
"nextval" (case-insensitive). In other words, inside the Token::Dot arm (where
parser.expect(Token::Dot)? and parser.expect(Token::Identifier) are used)
require s == "pg_catalog" && the next identifier.eq_ignore_ascii_case("nextval")
before returning true for is_nextval.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c3dbbaae-6b6a-4dbe-8cc7-2740814008df
📒 Files selected for processing (1)
schema-engine/sql-schema-describer/src/postgres/default.rs
Accept schema-qualified nextval() calls (e.g. pg_catalog.nextval) when parsing Postgres integer defaults, and add coverage in parser tests.
f811693 to
7a130e3
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
This fixes a small parsing gap in Postgres introspection.
The parser already handled
nextval(), but not schema-qualified calls likepg_catalog.nextval(). In some setups, the database can return the qualified form (not specified), so sequence defaults could be missed.This PR updates the parser to recognize both forms and adds a test.