Skip to content

fix(snowflake): null-guard getByType and use Objects.equals for incrementValue - #2139

Merged
openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/2131-snowflake-sqlbuilder
Jul 26, 2026
Merged

fix(snowflake): null-guard getByType and use Objects.equals for incrementValue#2139
openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/2131-snowflake-sqlbuilder

Conversation

@Aias00

@Aias00 Aias00 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Related issue

Closes #2131

Summary

Fixes two correctness issues in SnowflakeSqlBuilder:

  1. Equal boxed Long increment values are now compared with Objects.equals, preventing a spurious AUTOINCREMENT alteration caused by reference comparison.
  2. Unknown Snowflake column or index metadata no longer causes a null dereference or gets silently omitted from generated DDL. The builder now fails fast with an IllegalArgumentException that includes the unsupported type. Silent omission would produce apparently successful but incomplete table DDL.

Affected surfaces

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

Verification

  • Commands and results:
    • mvn -pl chat2db-community-plugins/chat2db-community-snowflake -am -Dmaven.test.skip=false -DskipTests=false -Dtest=SnowflakeSqlBuilderTest -Dsurefire.failIfNoSpecifiedTests=false test - passed.
    • SnowflakeSqlBuilderTest - 3 tests passed: unknown column type, unknown index type, and equal boxed increment values.
  • Manual verification: Reviewed all three getByType call sites to confirm that unsupported metadata cannot be silently dropped from CREATE or ALTER output.
  • UI evidence: N/A

Risk and compatibility

  • Public API or stored data: N/A; no API or persistence changes.
  • Database or driver compatibility: Recognized Snowflake types retain existing behavior. Unsupported metadata now returns a specific error instead of an NPE or incomplete DDL.
  • Network, privacy, or security: N/A.
  • Community / Local / Pro boundary: N/A; this is isolated to the Community Snowflake plugin.
  • Backward compatibility: Corrects erroneous DDL generation. Callers that supplied unsupported types now receive a descriptive exception.

Reviewer map

  • Start here: SnowflakeSqlBuilder.requireColumnType, requireIndexType, and SnowflakeSqlBuilderTest.
  • Failure condition: Equal increment values emit AUTOINCREMENT, or unsupported types are omitted without an error.
  • Rollback or disable path: Revert the two commits in this PR.

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 original contribution used Claude Code. A maintainer used Codex to correct the unsupported-metadata behavior and add regression coverage.

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

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 and others added 2 commits July 26, 2026 14:00
…mentValue

getByType returns null for unrecognized types; the builder dereferenced
it in three loops (create columns, indexes, modify columns), NPE-ing.
Add if (... == null) continue guards, mirroring every sibling builder.
Also, buildAlterTable compared Long incrementValue with !=, which is
reference equality and emitted a spurious AUTOINCREMENT= on every
alter; use Objects.equals, mirroring MysqlSqlBuilder.

Fixes OtterMind#2131

Co-Authored-By: Claude <noreply@anthropic.com>
@openai0229
openai0229 force-pushed the fix/2131-snowflake-sqlbuilder branch from 5ae1507 to e52fbb1 Compare July 26, 2026 06:26

@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.

Thank you for the contribution. I corrected the unsupported-type path so it fails with a descriptive error instead of silently dropping DDL elements, added three regression tests, and verified the Snowflake module on current main. Approved.

@openai0229
openai0229 merged commit 18cb42b into OtterMind:main Jul 26, 2026
14 of 16 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Jul 26, 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.

SnowflakeSqlBuilder uses != on Long incrementValue and skips null-guard on getByType

3 participants