Repository navigation
Conversation
A query returning one column scans it into a variable named after the column, with only $ replaced. A database may name a column anything, as SQL Server names a pivoted column 2023, a FOR JSON result JSON_F52E2B61-18A1-11d1-B105-00805F49916B, and a bracketed alias [total amount], each of which generated code that did not compile. Every character a Go identifier cannot hold is now replaced, and a leading digit prefixed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
goIdent checked the first byte of a column name for a digit, so a name starting with a non-ASCII digit, such as [١total], kept it and did not compile, and a name with no identifier characters at all, such as [!], became the blank identifier. The first rune is now checked, and a name left with nothing but underscores falls back to column_1, as an unnamed column is called. Addresses review comment r4557024827 on #1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ssql.Money decimal, numeric, money and smallmoney mapped to string, leaving each caller to parse it. They now map to shopspring's decimal, which go-mssqldb already depends on and sends as a decimal, as ClickHouse's decimals map, and money to the driver's Money over it, which it sends as money. A generic type's argument brings its package's import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
go-mssqldb sends a NULL mssql.NullUniqueIdentifier passed by value as a GUID of length 0 followed by 16 bytes, which SQL Server rejects with error 8009, so a generated query could not pass NULL for one. A nil *mssql.UniqueIdentifier it sends as NULL, and scans NULL into, so a nullable uniqueidentifier now maps to that. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EliSauder
commented
Nov 13, 2026
Inject an optional Go type mapper through compiler results and built-in generator assembly. Keep nullable-pointer rendering and recursive generic import matching shared, preserving legacy engine fallbacks and user override precedence. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EliSauder
force-pushed
the
mssql/go-types
branch
from
November 13, 2026 18:29
afdcee8 to
5f04dd3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go code generated for SQL Server.
2023or[total amount].decimal.Decimal(shopspring, which go-mssqldb uses) and money/smallmoney tomssql.Money[...], as ClickHouse's decimals map; verified round-tripping 38 digits and NULL.*mssql.UniqueIdentifier: go-mssqldb sends a NULLmssql.NullUniqueIdentifierby value as a malformed GUID (TDS error 8009, still in v1.11.2).Commits
a43976a36fix(golang): make a single result column's variable a Go identifier9ef6bba75fix(golang): read a result variable's first character as a runedeeeed207fix(golang): map SQL Server decimal to decimal.Decimal and money to mssql.Moneye604a5a0afix(golang): map a nullable uniqueidentifier to *mssql.UniqueIdentifier5f04dd381refactor(mssql): own Go type mappings and import metadata in the engineType and import dependency inversion
The engine implements a neutral
GoTypeMappercontract describing the value type, nullable wrapper, array completeness, and dependency imports. Compiler results carry the optional mapper; the built-in Go assembly injects it at runtime. The Go generator retains override precedence, nullable-pointer rendering, and its existing recursive matching of generic type arguments. It no longer owns SQL Server type mappings, the go-mssqldb import path, or a Money-specific import match.Other engines retain their existing fallback mappings. External generators and the plugin protocol are unchanged; the mapper is not a serialized configuration option.
The focused end-to-end fixture covers money-only generic dependencies, nullable money/UUID values, pointer mode, database-type overrides, and column overrides with a different package using the same qualifier. Its goldens were generated with the unmodified PR head and match after the refactor.
Test changes for independence
mssql_result_variable_name: the column named2023comes from an alias rather than a PIVOT, which is in the core PR.Independence. This is one of five PRs split from #1, each off
mainwith no dependency on the others. Existing goldens remain unchanged. The compiler and Go generator assembly points overlap #6's execution-capability inversion; retain both optional providers when integrating those edits.Verification. SQL behavior was checked against SQL Server 2025 in #1 (goldeneye or
sp_describe_*). For this refactor, the complete base replay corpus, targeted cross-engine type/override cases, touched-package race tests, targetedgo vet, and CLI build pass. The existing SQL Server type golden and all three new generated Go packages compile and pass Go's default vet checks.