Skip to content

Fix editable key columns after clearing legacy names - #2775

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/key-column-clear-append-20261011
Oct 13, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/key-column-clear-append-20261011

Conversation

@minleejae

@minleejae minleejae commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Allow callers to clear an index or constraint's legacy column names and then repopulate its structured key list. Today key.setColumnsNames(null) followed by addColumns(...) throws UnsupportedOperationException.

Current design (As-is)

The shared KeyColumnSource.setColumnsNames(null) installs Collections.emptyList(). Index, primary/unique key, foreign key and exclusion constraint nodes retain that list. Their fluent appenders expect an editable list, so null-clear behaves differently from an empty-name replacement.

Target design (To-be)

Use an empty ArrayList in the shared null-clear path. Both null and empty name lists clear the keys and leave them editable through getColumns() and the existing addColumns overloads. The legacy accessor still returns a rendered snapshot; replacing names still creates opaque keys and discards prior element-specific options. Indexes and constraints remain separate types.

key.setColumnsNames(null);
key.getColumns().add(new KeyElement("id"));

Validation

  • Regression coverage exercises indexes, primary keys, unique keys, foreign keys and exclusion constraints, with null/empty clears, collection/varargs appenders and direct structured-list edits.
  • Both toString() and StatementDeParser preserve the restored SQL and key options; rendered statements reparse successfully.
  • Default PMD complexity and field-placement rules: zero violations for the changed shared interface.
  • Java 17 offline Gradle spotlessApply check: 10,045 tests, 10,020 passed, 25 skipped, zero failures/errors. Grammar, Checkstyle, PMD, SpotBugs and coverage checks pass.

Integration validation

Applied #2770, #2771 and all four follow-ups (#2775–#2778) together on master (066f581e), resolving overlapping validator edits while preserving their respective behavior. The integrated build passes Java 17 offline Gradle spotlessApply check: 10,141 tests, 10,116 passed, 25 skipped, zero failures/errors. The combined ALTER validator has zero findings under the default PMD complexity and field-placement rules.

Replayed 882 previously DB-validated MySQL/PostgreSQL DDL fixtures: 875 pass and the same seven existing parse gaps remain. SQL output, reparsing and AST node-type sets match the preceding integration baseline, with no new differences. This replay did not rerun the databases.

The published head passes grammar checks, Gradle and Maven on Ubuntu/Windows/macOS, and Codacy. Deployment-only jobs are skipped as expected for a PR.

Signed-off-by: minleejae <mmj9808@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants