Skip to content

fix(kingbase): use double-quote for DROP COLUMN identifier - #2145

Closed
Aias00 wants to merge 1 commit into
OtterMind:mainfrom
Aias00:fix/2142-kingbase-drop
Closed

fix(kingbase): use double-quote for DROP COLUMN identifier#2145
Aias00 wants to merge 1 commit into
OtterMind:mainfrom
Aias00:fix/2142-kingbase-drop

Conversation

@Aias00

@Aias00 Aias00 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Related issue

Closes #2142

Summary

KingBase is PostgreSQL-derived and quotes identifiers with double quotes everywhere else (KingBaseMetaData, SQL_ALTER_COLUMN, buildCreateColumnSql). But the DROP-column path used MySQL-style backticks: SQL_DROP_COLUMN = "DROP COLUMN ``" and column.getName() + "``", producing DROP COLUMN ``name``` which is invalid KingBase SQL. Changed both to double-quote quoting, mirroring the PostgreSQL sibling (PostgreSQLColumnTypeEnumConstants`).

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • Commands and results: mvn -B -q -f chat2db-community-server/pom.xml -pl chat2db-community-plugins/chat2db-community-kingbase -am -Dmaven.test.skip=true compile -> BUILD SUCCESS.
  • Manual verification: DROP COLUMN now emits DROP COLUMN "name" (double-quoted), valid KingBase SQL.
  • UI evidence: N/A

Risk and compatibility

  • Public API or stored data: N/A — only changes generated DROP DDL quoting.
  • Database or driver compatibility: KingBase DROP COLUMN now produces valid SQL; previously invalid.
  • Network, privacy, or security: N/A.
  • Community / Local / Pro boundary: N/A.
  • Backward compatibility: Only fixes invalid SQL; no API change.

Reviewer map

  • Start here: KingBaseColumnTypeEnumConstants.java:20DROP COLUMN `` -> DROP COLUMN "; KingBaseColumnTypeEnum.java:142column.getName() + "``"->column.getName() + """`.
  • Failure condition: DROP COLUMN still uses backticks.
  • Rollback or disable path: Revert this single commit.

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.

Copilot AI review requested due to automatic review settings July 26, 2026 06:11
@Aias00
Aias00 requested a review from openai0229 as a code owner July 26, 2026 06:11

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.

KingBase is PostgreSQL-derived and uses double-quote identifiers
everywhere, but DROP COLUMN used MySQL-style backticks, producing
invalid SQL. Use double quotes, mirroring PostgreSQL.

Fixes OtterMind#2142

Co-Authored-By: Claude <noreply@anthropic.com>
@openai0229
openai0229 force-pushed the fix/2142-kingbase-drop branch from 5cdc4f6 to 23773e1 Compare July 26, 2026 09:37

@openai0229 openai0229 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed against the current main branch. The Kingbase DROP COLUMN quoting change is focused and correct, the relevant modules compile and tests pass, and I found no remaining code blocker. Thank you for the contribution.

@Aias00

Aias00 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Live-database verification (PostgreSQL 16)

Tested the same bug class (unquoted DROP COLUMN on mixed-case identifiers) against a live PostgreSQL 16 container:

Fix (quoted): ALTER TABLE "TestSchema"."TestTable" DROP COLUMN "mixedCaseCol" → ✅ ALTER TABLE (success)

Old behavior (unquoted): ALTER TABLE "TestSchema"."TestTable" DROP COLUMN mixedCaseCol → ❌ ERROR: column "mixedcasecol" of relation "TestTable" does not exist

PostgreSQL lowercases unquoted identifiers, so mixed-case column names can only be dropped with double-quote quoting. KingBase (PG-derived) has the same behavior.

@Aias00

Aias00 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #2261 which uses the SPI quoteIdentifierAlways method per the maintainer review on #2187.

@Aias00 Aias00 closed this Jul 27, 2026
@openai0229 openai0229 moved this to Done in Chat2DB Community Jul 27, 2026
Aias00 added a commit to Aias00/Chat2DB that referenced this pull request Jul 27, 2026
Replaces direct backtick concatenation with
KingBaseMetaData.KINGBASE_SQL_IDENTIFIER_PROCESSOR.quoteIdentifierAlways,
per the maintainer review on OtterMind#2187. Built on the SPI extension (OtterMind#2234).

Closes OtterMind#2145 (superseded by this SPI-based approach)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

KingBase DROP COLUMN uses backtick quoting instead of double quotes (invalid SQL)

3 participants