Fix index/constraint column not shown when its name requires quoting (#6481)#10039
Fix index/constraint column not shown when its name requires quoting (#6481)#10039dpage wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 7 minutes and 26 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR fixes issue ChangesQuoted Identifier Fix for Index and Constraint Columns
🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
b1b1a54 to
ea60e15
Compare
…g#6481 The is_exp flag compared pg_get_indexdef() (which returns the SQL-quoted identifier) directly against a.attname (the raw name). For any column name needing quoting these differ, so a plain column was wrongly treated as an expression and not rendered, and validation reported it empty. Compare against pg_catalog.quote_ident(a.attname) instead, which matches pg_get_indexdef()'s output for both normal and quoted names; real expressions (attname NULL) still evaluate as expressions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ea60e15 to
464cc15
Compare
asheshv
left a comment
There was a problem hiding this comment.
The SQL fix (comparing against quote_ident(a.attname) instead of a.attname) is correct — is_exp will now classify properly. But the Python side that displays the column name is still broken for the exact category the PR claims to fix.
web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/utils.py:123 uses attdef.strip('"'). str.strip('"') strips outer quotes but doesn't unescape doubled inner quotes. For a column named col"x, pg_get_indexdef returns "col""x"; .strip('"') yields col""x, not col"x. So the properties panel still displays the wrong name for any identifier containing a literal ".
Pull this into a tiny helper:
def unquote_ident(s):
if s.startswith('"') and s.endswith('"'):
return s[1:-1].replace('""', '"')
return sTests gap: no scenarios for quoted-identifier column names (uppercase, spaces, reserved words, embedded "). The regression that caused #6481 wouldn't have been caught by existing tests, and this PR doesn't add coverage for it.
Summary
Fixes #6481.
When an index (or exclusion constraint) column name requires quoting — e.g. it contains a double quote or other special characters — the column was not shown in the Properties panel, and editing reported it as empty.
Root cause: the
is_exp(expression) flag is computed aspg_get_indexdef(...) = a.attname.pg_get_indexdef()returns the SQL-quoted identifier (e.g."col""x") whilea.attnameis the raw name (col"x). For any name needing quoting these never match, so a plain column was misclassified as an expression and dropped.Fix: compare against
pg_catalog.quote_ident(a.attname), which yields the same quoted form aspg_get_indexdef()for both normal and special names. Real expression indexes (whereattnameis NULL) still evaluate as expressions.Changes
indexes/sql/11_plus/column_details.sql,indexes/sql/default/column_details.sql,exclusion_constraint/sql/default/get_constraint_cols.sql🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Documentation
Bug Fixes