feat(dialect): support Microsoft SQL Server in ent #4474
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.
Summary
This PR adds Microsoft SQL Server (MSSQL) dialect support to the ent entity framework.
Core SQL Server dialect implementation
dialect/dialect.goSQLServer = "sqlserver"constantdialect/sql/builder.go[brackets]identifier quoting,@pNparameter placeholders,OFFSET/FETCHpagination syntaxdialect/sql/builder_test.godialect/sql/driver.godialect/sql/schema/sqlserver.godialect/sql/schema/atlas.godialect/sql/schema/writer.godialect/sql/sqlgraph/graph.godialect/sql/sqljson/*.goCode generation
entc/gen/storage.godialect.SQLServerto SQL dialects listentc/integration/*/ent/client.goCI/Testing
.github/workflows/ci.ymlentc/integration/docker-compose.yamlentc/integration/integration_test.goTestSQLServerfunctionentc/integration/go.modgithub.com/microsoft/go-mssqldbdriver dependencySQL Server Features Implemented
[brackets]@p1, @p2, ...syntaxOFFSET x ROWS FETCH NEXT y ROWS ONLY(auto-addsORDER BY (SELECT NULL)when missing)IDENTITY(1,1)for auto-increment columnsBITfor bool,NVARCHARfor strings,DATETIME2for time,UNIQUEIDENTIFIERfor UUIDJSON_VALUE,JSON_QUERY,OPENJSONfunctionsSCOPE_IDENTITY()for retrieving last inserted IDsKnown Limitation
The open-source Atlas Go library (
ariga.io/atlas) does not include a SQL Server driver. SQL Server support in Atlas is a Pro/Cloud-only feature. This means:migrate.Create()will fail with an error message directing users to Atlas CLI or manual migrationsFuture work could implement a WriteDriver-based migration approach to bypass Atlas for SQL Server.