Skip to content

fix(mysql): keep the original text of index expressions - #1033

Merged
huydo862003 merged 1 commit into
holistics:masterfrom
zzoraemon043:fix/mysql-expression-index-text
Nov 12, 2026
Merged

huydo862003 merged 1 commit into
holistics:masterfrom
zzoraemon043:fix/mysql-expression-index-text

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Summary

  • The MySQL parser built the text of an index expression with getText(), which joins the tokens without the whitespace between them, so CAST(value AS SIGNED) became CAST(valueASSIGNED) and the multi-valued index CAST(... AS UNSIGNED ARRAY) from the issue became ...ASUNSIGNEDARRAY. The DBML written by sql2dbml then holds expressions that are not valid SQL.
  • Index expressions now keep their original text through the existing getOriginalText helper, as the MSSQL parser already does.
  • Updated the expected outputs of mysql-parse/expression_indexes, mysql-parse/composite_pk and mysql_importer/ddl_create; the only changes are the restored spaces in index expressions (the ddl_create output had ASUNSIGNEDARRAY before).

Default value expressions go through getText() the same way, I left them out to keep this to indexes.

Issue

Fixes #578

Lasting Changes (Technical)

  • None, only the value of expression index columns from the MySQL parser changes.

Checklist

  • Documentation (if necessary)
  • Updated dbml-homepage/static/llms.txt (if docs/features changed)
  • Lint Checks Passed
  • Unit Tests Passed (npx vitest run in packages/dbml-core)
  • Coverage Tests Passed
  • Integration Tests Passed
  • Code Review

@huydo862003 huydo862003 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

@huydo862003
huydo862003 merged commit b07ed1a into holistics:master Nov 12, 2026
3 of 5 checks passed
@huydo862003 huydo862003 added the PR: Bug Fix 🐛 A type of pull request used for changelog categories label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 A type of pull request used for changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with multi-valued index expressions - sql2dbml mysql

2 participants