Repository navigation
Conversation
A statement the converter does not handle, such as MERGE or EXEC, was skipped, so a query named on one silently went missing from the generated code. Skipping is right for a schema, which holds statements sqlc has no use for, but a statement carrying a query name is now reported as unsupported, at the statement. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A named query on a statement sqlc cannot analyze is reported rather than dropped, but the check only recognized a -- name: comment, so a MERGE named with /* name: Foo :exec */, which sqlc also reads, was still dropped silently. Both comment styles are now recognized. Addresses review comment r4557025570 on #1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TOP n PERCENT was skipped as no row count, which dropped a placeholder in it from the query's parameters, so the generated code did not pass it and the query failed with an undeclared variable. The percentage is now analyzed as the float SQL Server takes it as. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Checking a :copyfrom query read the FROM list of its INSERT ... VALUES without checking it was there. PostgreSQL's converter gives VALUES an empty one, but SQL Server's leaves it nil, so any :copyfrom query on SQL Server panicked. It now reaches the generator, which reports that :copyfrom is not supported for the driver. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
go-mssqldb never reports a last insert ID: its LastInsertId always returns an error, so the code generated for an :execlastid query failed every time it ran. Generating one is now an error that points at the OUTPUT INSERTED clause SQL Server returns the ID with. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A placeholder in a construct the converter does not follow, as TABLESAMPLE (@n PERCENT) or CONVERT's style, was dropped from the query's parameters, generating code that passed the query too few arguments. Every @name in a named query's text, outside strings, quoted names and comments, must now be one of its parameters, and one that is not is reported where it is. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A style given as a placeholder, as CONVERT(nvarchar(30), at, @Style), was dropped. It is now passed as an int, through a function returning the converted value, which may then be NULL; a literal style is left as it was. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EliSauder
commented
Nov 13, 2026
Expose optional engine-owned driver capabilities through compiler results. Apply LastInsertId restrictions only to built-in Go generation, preserving other engines and external generators. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EliSauder
force-pushed
the
mssql/unsupported-constructs
branch
from
November 13, 2026 18:29
7d2ec33 to
41ae5fa
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.
Things sqlc silently got wrong, or panicked on, for SQL Server now either work or fail with a clear error.
@namea named query has that did not become a parameter.:copyfromno longer panics; built-in Go generation rejects:execlastidfor its go-mssqldb binding, whoseLastInsertIdalways errors. External generators are not restricted.Commits
9f1f67abafix(mssql): report a named query sqlc cannot analyze0f527029afix(mssql): report an unsupported query named in a block comment982cee5aefix(mssql): keep the placeholder in TOP (@n) PERCENTdeffbd571fix(validate): allow an INSERT whose VALUES has no FROM list4c03a9a89fix(golang): reject :execlastid for SQL Serveraef45f655fix(mssql): report a placeholder the converter drops3908e041dfix(mssql): keep the placeholder in CONVERT's style41ae5fab4refactor(mssql): supply driver execution capabilities to Go generationDriver capability inversion
The SQL Server engine owns the go-mssqldb restriction and diagnostic behind an optional, generic execution-capability provider. Compiler results carry the provider; the built-in Go assembly supplies the selected SQL package and driver and injects its capabilities into Go generation. Go codegen no longer chooses this restriction by engine name.
Engines without a provider retain their existing behavior. Other driver bindings do not inherit the go-mssqldb restriction, and external process/WASM generators receive unchanged plugin requests. No plugin protocol or serialized configuration changes are required.
End-to-end coverage preserves the existing explicit
database/sqldiagnostic, adds the default SQL-package case, and verifies a SQL Server:execlastidquery reaches an external generator successfully. The complete base replay corpus, focused last-ID cases across engines, touched-package tests with the race detector, targetedgo vet, and CLI build pass.Test changes for independence
analyze_top_percent, rather than the core PR'sanalyze_paging.Independence. This is one of five PRs split from #1, each off
mainwith no dependency on the others: it builds, passes the base suite and keeps the core context at or abovemain's, alone. Its goldens are generated on this branch, and they hold unchanged with all five merged, whose code then equals the original branch. Parallel PRs add lines next to each other inconvert.go,functions.jsonland the dialect settings, so whichever merges later may need a rebase that keeps both sides.Verification. Behavior was checked against SQL Server 2025 in #1 (goldeneye or
sp_describe_*).go test ./internal/endtoend -run TestReplay/base/and the touched packages' tests pass; generated Go goldens passgo vet.