Skip to content

fix(db2): skip column comment for dropped columns in ALTER#2083

Merged
openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/2078-db2-drop-comment
Jul 25, 2026
Merged

fix(db2): skip column comment for dropped columns in ALTER#2083
openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/2078-db2-drop-comment

Conversation

@Aias00

@Aias00 Aias00 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Related issue

Closes #2078

Summary

DB2SqlBuilder.buildAlterTable appended a COMMENT ON COLUMN whenever the column's comment was non-blank, including for a DELETE-status column. For such a column, buildModifyColumn emits ALTER TABLE ... DROP COLUMN "c", then the code appended COMMENT ON COLUMN "schema"."table"."c" IS '...' for the just-dropped column, producing invalid SQL. Added the && !EditStatusEnum.DELETE.name().equals(tableColumn.getEditStatus()) guard (and the EditStatusEnum import), mirroring Oracle (OracleSqlBuilder.java:184-185) and DM.

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-db2 -am -Dmaven.test.skip=true compile -> BUILD SUCCESS.
  • Manual verification: For ADD/MODIFY columns with a comment, the COMMENT clause is still emitted (unchanged). For DROP columns, the COMMENT clause is now skipped, avoiding the invalid statement.
  • UI evidence: N/A

Risk and compatibility

  • Public API or stored data: N/A — only changes generated ALTER text for DROP columns.
  • Database or driver compatibility: DB2 ALTER no longer emits an invalid COMMENT for dropped columns; other paths unchanged.
  • 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: DB2SqlBuilder.buildAlterTable — comment condition now StringUtils.isNotBlank(tableColumn.getComment()) && !EditStatusEnum.DELETE.name().equals(tableColumn.getEditStatus()); new EditStatusEnum import.
  • Failure condition: ALTER for a DROP column still appends a COMMENT ON COLUMN for the dropped column.
  • 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.

buildAlterTable appended COMMENT ON COLUMN whenever the comment was
non-blank, including for a DROP-status column whose DROP COLUMN was
emitted just before, producing invalid SQL. Guard with
!EditStatusEnum.DELETE, mirroring Oracle/DM.

Fixes OtterMind#2078

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

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.

@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 the final DB2 DROP COLUMN fix at fbf69e0. The change only suppresses COMMENT ON COLUMN for DELETE-status columns, matching the existing Oracle/DM behavior; the previous head passed backend checks and Java CodeQL, and the final synchronized head is running the required validation.

@openai0229
openai0229 merged commit c68abb1 into OtterMind:main Jul 25, 2026
17 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Jul 25, 2026
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.

DB2 buildAlterTable appends a column comment for a DROPped column (invalid SQL)

3 participants