Skip to content

fix: refresh index classification when replacing its type - #2645

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/index-kind-state
Sep 20, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/index-kind-state

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

Changing an existing index from UNIQUE to INDEX updates its rendered type but leaves getKind() at UNIQUE. Consumers rewriting CREATE/ALTER TABLE statements can therefore observe a classification that no longer matches the type they assigned.

Derive the classification on every setType/withType call through one helper. Null and custom types clear stale classifications, keyword matching respects word boundaries, and original spelling is preserved. setKind remains an explicit metadata override without rewriting SQL, supporting declarations that store the index keyword separately and specialized constraint nodes.

Validation: Gradle check passed (7502 tests, 0 failures, 0 errors, 25 skipped), including formatting, static analysis and the grammar check. Regression tests cover repeated edits, all prior classifications, custom/null types, subclass defaults and CREATE TABLE deparse/reparse. Eight original/rewritten DDL cases executed successfully on MySQL 8.4.11 and PostgreSQL 18.6.

Syntax references: MySQL CREATE TABLE, PostgreSQL CREATE TABLE.

@manticore-projects
manticore-projects merged commit d1dbca1 into JSQLParser:master Sep 20, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

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