Skip to content

fix(postgresql,kingbase): quote foreign schema and table in REFERENCES#2187

Open
Aias00 wants to merge 1 commit into
OtterMind:mainfrom
Aias00:fix/2184-pg-kingbase-fk-quote
Open

fix(postgresql,kingbase): quote foreign schema and table in REFERENCES#2187
Aias00 wants to merge 1 commit into
OtterMind:mainfrom
Aias00:fix/2184-pg-kingbase-fk-quote

Conversation

@Aias00

@Aias00 Aias00 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Related issue

Closes #2184

Summary

PostgreSQLIndexTypeEnum.buildForeignColum (and the identical KingBaseIndexTypeEnum) concatenated getForeignSchemaName() and getForeignTableName() raw into the REFERENCES clause, while the foreign columns below were double-quoted. PostgreSQL/KingBase fold unquoted identifiers to lowercase, so a foreign table with an uppercase/mixed-case name produced a REFERENCES clause pointing at a non-existent relation. Wrapped both in double-quotes, matching the column quoting in the same method. Applied to both PostgreSQL and KingBase.

Verification

  • mvn compile -> BUILD SUCCESS.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below, or this PR contains no substantial AI-generated code.

AI assistance: The fix, verification, and PR description were produced with Claude Code assistance.

The foreign schema and table were concatenated raw while the foreign
columns below were double-quoted. PostgreSQL/KingBase fold unquoted
identifiers to lowercase, so mixed-case foreign table names produced a
REFERENCES clause pointing at a non-existent relation. Wrap in
double-quotes, matching the column quoting in the same method.

Fixes OtterMind#2184

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 26, 2026 15:08
@Aias00
Aias00 requested a review from openai0229 as a code owner July 26, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Aias00

Aias00 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Live-database verification (PostgreSQL 16)

  • Quoted FK: REFERENCES "TestSchema"."TestTable" ("anotherCol") → ✅ CREATE TABLE
  • Unquoted table: REFERENCES "TestSchema".TestTable ("anotherCol") → ❌ ERROR: relation "TestSchema.testtable" does not exist

The foreign columns were already double-quoted in the same method; this fix quotes the schema and table to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

PostgreSQL/KingBase foreign-key REFERENCES leaves schema and table unquoted

3 participants