Skip to content

feat(parser): add column data type fragment parser - #2531

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/parse-column-data-type
Open

feat(parser): add column data type fragment parser#2531
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/parse-column-data-type

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

What

  • Add CCJSqlParserUtil.parseColDataType(String).
  • Add a configurable overload accepting Consumer<CCJSqlParser> for dialect and feature settings.
  • Require the complete input to be consumed, rejecting trailing column constraints or modifiers instead of returning a partial type.
  • Cover PostgreSQL array dimensions, MySQL ENUM arguments, parser configuration, null/empty input, and partial-input rejection.

Why

ColDataType() is available on the generated parser, but there is no public CCJSqlParserUtil entry point for applications that receive a type fragment rather than a complete DDL statement. Such applications currently need to instantiate the generated parser directly or wrap the fragment in synthetic DDL.

The strict EOF check is important for type fragments: returning varchar(255) from varchar(255) NOT NULL would silently discard meaningful input.

API example

ColDataType type = CCJSqlParserUtil.parseColDataType(
        "enum('small','medium')",
        parser -> parser.withDialect(AbstractJSqlParser.Dialect.MYSQL));

Testing

  • ./gradlew check
  • Added focused tests in CCJSqlParserUtilTest.

AI assistance

OpenAI Codex was used to review existing parser utility conventions, prepare the API and tests, and run validation. The generated change was reviewed for strict full-input behavior and compatibility with parser configuration.

Expose strict CCJSqlParserUtil helpers for ColDataType fragments, including parser configuration and full-input validation.
@minleejae
minleejae force-pushed the feat/parse-column-data-type branch from 8753b98 to a0556bd Compare September 3, 2026 06:26
@minleejae
minleejae marked this pull request as ready for review September 3, 2026 07:05
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.

1 participant