GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Render single spaces in ALTER visibility, FORCE and row level security actions by minleejae · Pull Request #2819 · JSQLParser/JSqlParser

Conversation

@minleejae

@minleejae minleejae commented Oct 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Purpose

Follow-up to #2792. More renderers emit stray spaces. Today:

  • ALTER TABLE t ALTER COLUMN c SET INVISIBLE renders SET INVISIBLE (also SET VISIBLE, and the form without COLUMN).
  • ALTER TABLE t ALTER INDEX i INVISIBLE renders ALTER INDEX i INVISIBLE.
  • ALTER TABLE t FORCE ends with a space, and FORCE, ALGORITHM = INPLACE renders FORCE , ALGORITHM = INPLACE.
  • PostgreSQL ALTER TABLE t {ENABLE | DISABLE | FORCE | NO FORCE} ROW LEVEL SECURITY ends with a space.
  • ALTER TABLE t MODIFY (c INT) renders MODIFY ( c INT ) . ADD CONSTRAINT UNIQUE KEY uk (a) renders uk (a).
  • The Index of CREATE INDEX ON t (a) renders (a) when printed on its own.
  • MySQL DEFAULT (JSON_ARRAY()) renders DEFAULT (JSON_ARRAY( ) ), and JSON_OBJECT() renders JSON_OBJECT( ) .

The SQL still reparses, but the extra spaces differ from the input.

Current design (As-is)

  • ColumnSetVisibility appends " SET " and then " VISIBLE" or " INVISIBLE".
  • Index puts two spaces before its trailing index spec when it has no columns. It also puts a space before the column list even when nothing precedes it.
  • The general AlterExpression body appends a space after the operation keyword even when no payload follows. The row level security keywords add the same space.
  • A bracketed single column definition is wrapped in " ( " and " ) ". The ADD CONSTRAINT <type> <name> header ends with a space before the column list's own separator.
  • JSON_ARRAY and JSON_OBJECT always open with "( " and close with ") " or " ) ", even with no arguments.

Target design (To-be)

  • Separate these words with exactly one space and add no leading or trailing space:
    • ALTER COLUMN c SET INVISIBLE, ALTER INDEX i INVISIBLE, FORCE and ... ROW LEVEL SECURITY;
    • MODIFY (c INT), ADD CONSTRAINT UNIQUE KEY uk (a);
    • an Index with no declaration renders (a).
  • JSON_ARRAY() and JSON_OBJECT() render without inner spaces. No space follows the closing parenthesis. Calls with arguments keep their current inner spacing.
  • The legacy EXCHANGE PARTITION ... WITH VALIDATION rendering of a plain AlterExpression drops its trailing space.
  • Rendered SQL is otherwise unchanged. The SQL renderer and StatementDeParser produce the same text. The grammar is unchanged.

Validation

  • DeparseWhitespaceTest (added in Render single spaces in DROP PRIMARY KEY, RENAME TABLE and indexes #2792) now also:
    • compares toString() and StatementDeParser output exactly for the forms above in MySQL, PostgreSQL and default mode;
    • checks that JSON_ARRAY/JSON_OBJECT with arguments or ON NULL clauses render no double space;
    • checks ColumnSetVisibility, a constructed Index and a constructed EXCHANGE PARTITION action directly.
  • No existing assertion encoded these spaces, so no existing test changed.
  • Java 17 offline Gradle spotlessApply check: 10,382 tests, 10,357 passed, 25 skipped, zero failures/errors.
  • Compared with master (bdf8ac31) on a corpus of 635 MySQL 8.4 and PostgreSQL 18 DDL/DCL statements, each accepted by the server, with and without a dialect: no regressions. Only 6 MySQL and 3 PostgreSQL statements of the forms above change their toString(), in both dialect and default mode. In CREATE INDEX ON ..., the contained index renders (name) instead of (name).
  • MySQL 8.4 and PostgreSQL 18.3: every corpus statement this branch parses ran as written on one server and as rendered by toString() on a second, identical server, in the same order. All 205 MySQL and 328 PostgreSQL statements give the same result (success, or the same error).

Integration validation

Applied #2806–#2819 together on master (bdf8ac31), with the stacked PRs on top of their bases (#2806 → #2807 → #2808, #2806 → #2809 → #2810 and #2811 → #2812).

  • Each branch merges cleanly into master. Between the branches, conflicts are limited to adjacent additions (README/index rows, usage sections, imports, visitor and feature lists, one enum line and one alias guard).
  • The integrated build passes Java 17 offline Gradle spotlessApply check: 11,494 tests, 11,469 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes.
  • On a corpus of 635 MySQL 8.4 and PostgreSQL 18 DDL/DCL statements, each accepted by the server, the integrated build parses 265 of 271 MySQL statements (master: 206) and 363 of 364 PostgreSQL statements (master: 328). Every MySQL 8.4 non-reserved word and PostgreSQL 18 unreserved or column-name keyword parses as a column and table name.
  • On paired MySQL 8.4 and PostgreSQL 18.3 servers, all 263 MySQL and 362 PostgreSQL statements rendered by the integrated build give the same results as the originals.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@minleejae
fix: render single spaces in ALTER visibility, FORCE and row level se…
b79f20d
…curity actions

Rendered SQL had stray spaces in several ALTER TABLE actions:
SET  INVISIBLE, ALTER INDEX i  INVISIBLE, a trailing space after
FORCE and [NO] FORCE/ENABLE/DISABLE ROW LEVEL SECURITY, MODIFY  ( c INT ),
and ADD CONSTRAINT UNIQUE KEY uk  (a). An index without a declaration
printed a leading space, and argument-less JSON_ARRAY()/JSON_OBJECT()
rendered as JSON_ARRAY( ) and JSON_OBJECT(  ) with a trailing space.

Separate these words with exactly one space and add no leading or
trailing space. toString() and StatementDeParser stay identical.

Signed-off-by: minleejae <[email protected]>
This was referenced Oct 14, 2026
Share MySQL account names across CREATE USER and DEFINER #2806
Merged
Parse MySQL GRANT and REVOKE privilege levels, privileges and accounts #2807
Merged
Parse MySQL ALTER USER, RENAME USER and role statements with shared user options #2808
Merged
Keep routine signatures and owning tables in DROP statements #2809
Merged
Share typed MySQL index options across CREATE INDEX and table definitions #2810
Merged
Parse PostgreSQL ALTER DATABASE and share typed database options #2811
Merged
Parse ALTER FUNCTION, PROCEDURE and TRIGGER actions and MySQL routine definers #2812
Merged
Model MySQL column positions and attributes #2813
Merged
Model PostgreSQL ON COMMIT, access method and DROP behavior #2814
Merged
Allow more MySQL and PostgreSQL keywords as unquoted identifiers #2815
Merged
Extend PostgreSQL COMMENT ON targets #2816
Merged
Parse MySQL and PostgreSQL CREATE and ALTER TABLESPACE #2817
Merged
Parse PostgreSQL event triggers, REINDEX, SECURITY LABEL and schema elements #2818
Merged
Parse PostgreSQL Unicode escape string constants #2820
Merged
Expose MySQL table and partition comments as string values #2821
Merged
Parse COMMENT ON operators, operator classes, text search objects and large objects #2822
Merged
Parse MySQL SHOW FULL COLUMNS, SHOW TABLE STATUS and SHOW CREATE statements #2824
Merged
Model MySQL CREATE FUNCTION and PROCEDURE characteristics #2823
Merged
@manticore-projects
manticore-projects merged commit a36e771 into JSQLParser:master Oct 21, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@minleejae @manticore-projects
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.