Visitar URL original
fix(parse): keep the written order of index columns and expressions by zzoraemon043 · Pull Request #1009 · holistics/dbml · GitHub
Skip to content

fix(parse): keep the written order of index columns and expressions - #1009

Merged
huydo862003 merged 3 commits into
holistics:masterfrom
zzoraemon043:fix/index-column-order
Oct 19, 2026
Merged

huydo862003 merged 3 commits into
holistics:masterfrom
zzoraemon043:fix/index-column-order

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Summary

  • In an index that mixes columns and functional expressions, the interpreter pushed every expression first and then every column, so (country, `lower(name)`) became ((lower(name)), "country") in the exported DDL.
  • The columns and expressions of each index argument are now sorted back into source order (by token offset) before they are added.
  • Added an interpreter test with (a, `lower(b)`, c, `upper(c)`); it fails before the change.

Not touched here: the reversed order of juxtaposed fields like (a)(b) mentioned in the comments, since whether that form should be accepted is still open in #1008.

Issue

Fixes #1005

Lasting Changes (Technical)

  • None, only the order of Index.columns 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-parse)
  • 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 0a43e9e into holistics:master Oct 19, 2026
2 of 5 checks passed
@huydo862003 huydo862003 added PR: Dependencies Update 🤖 A type of pull request used for changelog categories PR: Bug Fix 🐛 A type of pull request used for changelog categories and removed PR: Dependencies Update 🤖 A type of pull request used for changelog categories labels Oct 28, 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.

Index columns change order when a functional expression comes after a column

2 participants