Skip to content

Make table option state transitions explicit - #2765

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:refactor/table-option-state-20261011
Oct 11, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:refactor/table-option-state-20261011

Conversation

@minleejae

@minleejae minleejae commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Make edits to CREATE/ALTER TABLE options observable through both their AST properties and SQL output. Replacing a typed option with raw tokens must not leave old values that reappear after another setter call.

Current design (As-is)

TableOption keeps raw tokens alongside its kind, name, value and structured children. setTokens() clears only some children; ordinary property setters can leave the raw tokens in control of rendering. Callers can therefore read stale typed properties or change an option without changing its emitted SQL. The storage-parameter deparser also ignores the current name and equals spelling.

Target design (To-be)

  • Give opaque tokens and structured properties explicit replacement rules. Non-null setTokens() clears all structured contents and selects OTHER; structured setters discard raw tokens. Tokens are not automatically parsed, and discarded state never returns.
  • Centralize content resets and use them when selecting UNION, storage parameters, foreign SERVER and TABLESPACE storage. Add setForeignTableOptions() to edit the existing SERVER model directly.
  • Keep ordinary typed edits incremental and make storage-parameter rendering agree with toString().
  • Document the collection contract: raw tokens remain editable; tokens derived from a structured option are an unmodifiable snapshot. Include migration and editing examples.

This changes the setter contract for mixed raw/structured usage. Callers that replace tokens should set the structured properties they need explicitly. SQL grammar is unchanged.

Validation

  • Java 17, offline Gradle spotlessApply check: 9,963 tests, 9,938 passed, 25 skipped, zero failures/errors. Grammar, formatting, Checkstyle, PMD, SpotBugs and coverage checks pass.
  • Eleven regression cases cover raw/typed transitions, clearing, UNION, PostgreSQL storage/SERVER options, MySQL TABLESPACE storage and consistent SQL rendering.
  • Built independently on current master (cdbaf1ad). No fresh live database execution was performed for this AST refactor.
  • Integration check with the other independent refactors (Use one foreign-key state in ALTER TABLE #2764–Expose editable ALTER column identity actions #2768): all five patches apply without conflicts; full Java 17 Gradle check passes with 10,030 tests (10,005 passed, 25 skipped). Replaying 882 previously DB-validated fixtures preserves the AST and both SQL outputs for 875 supported cases, with the same seven existing parse gaps and no semantic regression. No fresh database execution.

Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 6b67189 into JSQLParser:master Oct 11, 2026
10 checks passed
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