Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where camelCase column names were not properly quoted in the online SET NOT NULL rewrite path, causing PostgreSQL to fold them to lowercase and fail with "column does not exist" errors. The fix adds ir.QuoteIdentifier() calls for column names in the generated CHECK constraint expression and ALTER COLUMN statement.
Changes:
- Fixed missing identifier quoting for column names in
generateColumnNotNullRewritefunction - Added comprehensive test case with camelCase column names to validate the fix
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/plan/rewrite.go | Added ir.QuoteIdentifier() for column names in CHECK constraint and SET NOT NULL statements |
| testdata/diff/online/issue_313_camelcase_column_not_null/old.sql | Test schema with camelCase column before adding NOT NULL constraint |
| testdata/diff/online/issue_313_camelcase_column_not_null/new.sql | Test schema with camelCase column after adding NOT NULL constraint |
| testdata/diff/online/issue_313_camelcase_column_not_null/diff.sql | Expected simple migration SQL with quoted column name |
| testdata/diff/online/issue_313_camelcase_column_not_null/plan.sql | Expected online migration SQL with quoted column names |
| testdata/diff/online/issue_313_camelcase_column_not_null/plan.json | Expected JSON plan output with quoted column names |
| testdata/diff/online/issue_313_camelcase_column_not_null/plan.txt | Expected human-readable plan output |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryFixed missing identifier quoting for camelCase column names in online Changes made:
Test coverage:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 4b9e009 |
Summary
SET NOT NULLrewrite path (generateColumnNotNullRewriteininternal/plan/rewrite.go)offersValidUntil) were used unquoted in the generated CHECK constraint expression andALTER COLUMN ... SET NOT NULLstatement, causing PostgreSQL to fold them to lowercase and fail withcolumn "offersvaliduntil" does not existir.QuoteIdentifier()for the column name in the CHECK expression and SET NOT NULL statementFixes #313
Test plan
testdata/diff/online/issue_313_camelcase_column_not_null/with a table using camelCase column namesPGSCHEMA_TEST_FILTER="online/issue_313_camelcase_column_not_null" go test -v ./cmd -run TestPlanAndApplyPGSCHEMA_TEST_FILTER="online/" go test -v ./cmd -run TestPlanAndApply🤖 Generated with Claude Code