Skip to content

fix(parser): parse COMMENT ON ... IS NULL as comment removal (#2562) - #2563

Open
sundongkim-dev wants to merge 1 commit into
JSQLParser:masterfrom
sundongkim-dev:jsql-comment-is-null
Open

fix(parser): parse COMMENT ON ... IS NULL as comment removal (#2562)#2563
sundongkim-dev wants to merge 1 commit into
JSQLParser:masterfrom
sundongkim-dev:jsql-comment-is-null

Conversation

@sundongkim-dev

@sundongkim-dev sundongkim-dev commented Sep 8, 2026

Copy link
Copy Markdown

What

Parse COMMENT ON TABLE/COLUMN/VIEW ... IS NULL, PostgreSQL's syntax for removing a comment. For such statements Comment.getComment() returns null, and Comment.toString() deparses back to IS NULL.

Why

Fixes #2562. Per the PostgreSQL COMMENT docs: "To remove a comment, write NULL in place of the text string." Today this throws a ParseException, so DDL streams that drop comments cannot be processed.

How

The Comment() production required <S_CHAR_LITERAL> after <K_IS>; it is now a two-token choice <S_CHAR_LITERAL> | <K_NULL> (disjoint terminals, LL(1), no lookahead needed). For NULL the comment field simply stays null.

Comment.toString() now prints NULL when no comment string is set. This is required for the deparse round-trip and also changes new Comment().toString() from COMMENT ON IS null (string-concatenated Java null) to COMMENT ON IS NULL; the existing testToString expectation is updated accordingly.

Note for downstream consumers: a successfully parsed Comment could previously never have getComment() == null; after this change it can (exactly for IS NULL statements). All in-repo visitors (deparser, TablesNamesFinder, validators, feature visitor) are already null-safe here.

Testing

  • 4 new tests in CommentTest: TABLE/COLUMN/VIEW IS NULL parse + deparse round-trip, plus a lowercase is null sample.
  • ./gradlew test passes. spotlessJavaCheck reports 2 violations in files not touched by this PR (BytecodeSizeTest.java, CCJSqlParserTest.java), reproduced identically on pristine master.
  • Out of scope (unchanged behavior): PostgreSQL dollar-quoted comment strings (IS $$...$$) and COMMENT ON object types other than TABLE/COLUMN/VIEW still don't parse; IS NULL support is complete for the object types the grammar supports.

…ser#2562)

PostgreSQL removes a comment by writing NULL in place of the text
string, but the Comment() production required a string literal after
IS. Accept NULL as an alternative: the Comment's comment field stays
null and toString() deparses it back as IS NULL.
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.

[BUG] JSQLParser 5.3 : PostgreSQL : COMMENT ON ... IS NULL (comment removal) fails to parse

1 participant