Skip to content

feat: model MySQL expression-first CONVERT syntax - #2667

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:feat/mysql-convert-type
Sep 21, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:feat/mysql-convert-type

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

MySQL CONVERT(expression, type) is not represented by the existing CONVERT grammar, which primarily handles the SQL Server type-first form and character-set conversion with USING. Valid casts such as CONVERT(amount, DECIMAL(12,4)) therefore fail or are interpreted in the wrong argument order.

Replace the internal boolean syntax choice in TranscodingFunction with USING, TYPE_FIRST and TYPE_LAST variants, retaining the existing constructors and boolean accessors. Share its rendering with ExpressionDeParser so operand visitors and type mutations work consistently. Reuse ColDataType for lengths, precision and character-set clauses.

The MYSQL dialect selects expression-first parsing for ambiguous inputs such as CONVERT(value, CHAR). Default and SQLSERVER parsing retain the existing type-first precedence; callers processing ambiguous MySQL input should explicitly select Dialect.MYSQL. Regression coverage includes USING, SQL Server styles and TRY_CONVERT, nested conversions, NULL, parameters, type mutation and incomplete arguments.

Syntax reference: MySQL conversion functions.

Validation:

  • Full Gradle check passed on Java 17, including grammar ambiguity, formatting, static analysis, coverage and the full test suite. JUnit XML totals: 7997 tests, 0 failures/errors, 25 skipped.
  • MySQL 8.4.11: 20 cases (16 valid, 4 invalid). For all 16 valid cases, the original SQL, toString() output and StatementDeParser output executed successfully with matching query results or resulting schema state. Invalid inputs were rejected by the server.

Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 1eb5fc6 into JSQLParser:master Sep 21, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

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