Skip to content

feat(mssql): show precision/scale for decimal/numeric and length for char/nchar/binary - #883

Open
Tokyohenjin wants to merge 4 commits into
k1LoW:mainfrom
Tokyohenjin:feature/mssql-driver-output-details
Open

Tokyohenjin wants to merge 4 commits into
k1LoW:mainfrom
Tokyohenjin:feature/mssql-driver-output-details

Conversation

@Tokyohenjin

@Tokyohenjin Tokyohenjin commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

The MSSQL driver currently documents decimal and numeric columns without their precision and scale, and fixed-length char, nchar and binary columns without their length. For example, a decimal(9,2) column appears as just decimal, and char(5) as char. The variable-length types (varchar, nvarchar, varbinary) already include their length, so this makes the output consistent.

Changes

  • The column query in analyzeTable now also reads sys.columns.precision and sys.columns.scale.
  • convertColumnType formats:
    • decimal / numeric as decimal(p,s) / numeric(p,s)
    • char / binary as char(n) / binary(n)
    • nchar as nchar(n), halving max_length the same way nvarchar does
  • Added TestColumnTypePrecisionAndScale, covering explicit precision/scale, the implicit decimal(18,0) default, and the fixed-length types.

Behavior change

Generated docs for existing MSSQL schemas will change wherever these types appear. In particular, a column declared as bare decimal will now show as decimal(18,0), because the values come from sys.columns rather than the DDL text.

Samples

sample/mssql is unaffected, since testdata/ddl/mssql.sql doesn't use any of these types.

sample/azuresql needs regenerating: three decimal columns in testdata/ddl/azuresql.sql will now render as decimal(10,2) / decimal(12,2). I couldn't build the CLI locally due to local IT restrictions. Sorry for the extra step!

sample/azuresql is regenerated in commit 1abe749 and shows the updated values in tables and SVGs.

Testing

go test -tags mssql ./drivers/mssql/ passes against the local SQL Server container.

…es to `convertColumnType`

* `convertColumnType` - Reflect precision and scale for char, binary, nchar, decimal, and numeric column types.
@Tokyohenjin
Tokyohenjin marked this pull request as ready for review October 22, 2026 13:59
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