GeezerVison is showing github.com — Render single spaces in DROP PRIMARY KEY, RENAME TABLE and indexes by minleejae · Pull Request #2792 · JSQLParser/JSqlParser
Conversation
minleejae
commented
Oct 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Purpose
Render DDL with single spaces between words. Today:
ALTER TABLE t DROP PRIMARY KEY ends with a space, and with a parameter renders DROP PRIMARY KEY CASCADE.
RENAME TABLE t TO t2 renders RENAME TABLE t TO t2.
ALTER TABLE t ADD INDEX i (a) renders ADD INDEX i (a).
The SQL still reparses, but the extra spaces differ from the input and from each other.
Current design (As-is)
- The
DROP PRIMARY KEY renderer appends a trailing space. The shared tail adds its own space before parameters.
RenameTableStatement appends " TABLE " and then " " or " IF EXISTS ".
Index prefixes its keyword and name with a space even when no index type precedes them. An index with only a keyword or a name therefore renders a leading space.
Target design (To-be)
- Separate these words with exactly one space and add no leading or trailing space.
- Rendered SQL is otherwise unchanged. The SQL renderer and
StatementDeParser produce the same text.
Validation
- New
DeparseWhitespaceTest:
- Compares
toString() and StatementDeParser output exactly for DROP PRIMARY KEY (alone, with CASCADE, and followed by another action), RENAME (with and without TABLE, IF EXISTS, and several tables), ADD INDEX/ADD KEY, and an index inside CREATE TABLE.
- Checks constructed
Index declarations directly.
- Three existing assertions that encoded
ADD INDEX now expect a single space.
- Java 17 offline Gradle
spotlessApply check: 10,105 tests, 10,080 passed, 25 skipped, zero failures/errors.
- Ran the rendered statements on MySQL 8.4, MySQL 8.0 and MariaDB 11.4 (19 cases), including MariaDB
RENAME TABLE IF EXISTS. All succeed in original and rendered form.
Integration validation
Applied #2788, #2789, #2790, #2791 and #2792 together on master (166f0a27):
- Every pair merges without conflicts, and the combined grammar is free of choice conflicts.
- The integrated build passes Java 17 offline Gradle
spotlessApply check: 10,150 tests, 10,125 passed, 25 skipped, zero failures/errors.
- With the integrated build, the same server results hold on MySQL 8.4, MySQL 8.0, MariaDB 11.4 and PostgreSQL 18.3:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
DROP PRIMARY KEY ended with a space, which doubled before CASCADE or
RESTRICT. RENAME TABLE rendered two spaces before the first table, and
an index without a type rendered a leading space, so ALTER TABLE ... ADD
INDEX and named-only indexes came out with doubled spaces. Separate
these words with exactly one space; the SQL is otherwise unchanged.
Signed-off-by: minleejae <[email protected]>
This was referenced Oct 13, 2026
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|