Skip to content

compiler: Preserve matching sql table column types#2759

Open
sjh9714 wants to merge 1 commit into
terrastruct:masterfrom
sjh9714:fix-sql-table-identical-type-label
Open

compiler: Preserve matching sql table column types#2759
sjh9714 wants to merge 1 commit into
terrastruct:masterfrom
sjh9714:fix-sql-table-identical-type-label

Conversation

@sjh9714
Copy link
Copy Markdown

@sjh9714 sjh9714 commented May 24, 2026

Summary

Fixes #1960.

SQL table columns with an explicit type label equal to the column key, such as date: date, were compiled as if the type were implicit and ended up with an empty rendered type. This keeps matching explicit scalar labels while preserving empty types for implicit columns like id and map-only columns like created {constraint: primary_key}.

Changes

  • Only blank matching SQL column types when the column has no explicit scalar label.
  • Add a compiler regression test covering date: date, an implicit id, and a constraint-only column.

Testing

  • go test ./d2compiler -run TestCompile/sql-column-type-matches-name -count=1 failed before the fix with expected: "date", actual: "".
  • TESTDATA_ACCEPT=1 GOTOOLCHAIN=go1.25.0 go test ./d2compiler -run TestCompile/sql-column-type-matches-name -count=1
  • GOTOOLCHAIN=go1.25.0 go test ./d2compiler -run TestCompile/sql-column-type-matches-name -count=1
  • GOTOOLCHAIN=go1.25.0 go test ./e2etests -run TestE2E/stable/sql_table_tooltip_animated -count=1
  • GOTOOLCHAIN=go1.25.0 go test ./d2compiler -run 'TestCompile/sql' -count=1
  • GOTOOLCHAIN=go1.25.0 go test ./d2compiler -count=1
  • git diff --check

Note: I used Codex while preparing this change, and I reviewed the final diff and ran the listed checks locally.

Signed-off-by: jinhyuk9714 <jinhyuk9714@gmail.com>
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.

when label in sql_table is set to same as key, it doesn't work

1 participant