Conversation
Policy names were not being quoted in CREATE POLICY, ALTER POLICY, and DROP POLICY statements, causing SQL errors for policies with: - Reserved words as names (e.g., "select") - Mixed case names (e.g., "UserPolicy") - Special characters (e.g., "my-policy") Added ir.QuoteIdentifier() calls in: - internal/diff/policy.go: CREATE POLICY and ALTER POLICY - internal/diff/table.go: DROP POLICY statements Enhanced add_policy test case to cover all quoting scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #203 by adding proper identifier quoting for policy names in all DDL output statements. Policy names containing reserved words (e.g., "select"), mixed case (e.g., "UserPolicy"), or special characters (e.g., "my-policy") now generate valid SQL with quoted identifiers.
Key Changes:
- Added
ir.QuoteIdentifier()calls for policy names in CREATE POLICY, ALTER POLICY, and DROP POLICY statements - Enhanced test coverage with comprehensive examples covering reserved words, mixed case, special characters, and regular snake_case names
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/diff/policy.go | Added quoting to CREATE POLICY (line 65) and ALTER POLICY (line 107) statements |
| internal/diff/table.go | Added quoting to DROP POLICY statements for both dropped policies (line 918) and policies requiring recreation (line 1009) |
| testdata/diff/create_policy/add_policy/new.sql | Enhanced test case with four policies demonstrating different quoting scenarios |
| testdata/diff/create_policy/add_policy/old.sql | Added role column to support new test policies |
| testdata/diff/create_policy/add_policy/plan.txt | Updated expected output showing properly quoted policy names |
| testdata/diff/create_policy/add_policy/plan.sql | Updated expected DDL with quoted identifiers |
| testdata/diff/create_policy/add_policy/plan.json | Updated JSON plan with all four test policies and proper quoting |
| testdata/diff/create_policy/add_policy/diff.sql | Updated diff output showing all four policy creations with proper quoting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alecthomas
pushed a commit
to alecthomas/pgschema
that referenced
this pull request
Jan 26, 2026
Policy names were not being quoted in CREATE POLICY, ALTER POLICY, and DROP POLICY statements, causing SQL errors for policies with: - Reserved words as names (e.g., "select") - Mixed case names (e.g., "UserPolicy") - Special characters (e.g., "my-policy") Added ir.QuoteIdentifier() calls in: - internal/diff/policy.go: CREATE POLICY and ALTER POLICY - internal/diff/table.go: DROP POLICY statements Enhanced add_policy test case to cover all quoting scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #203
Policy names were not being quoted in CREATE POLICY, ALTER POLICY, and DROP POLICY statements, causing SQL errors for policies with:
Added ir.QuoteIdentifier() calls in:
Enhanced add_policy test case to cover all quoting scenarios.
🤖 Generated with Claude Code