{"modulePath":"github.com/flanksource/sqlglot-go","version":"v1.7.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sqlserver\n\nPackage sqlserver is the database half of the SQL Server dialect of the schema engine: it reads capabilities, schemas and the live dependents of columns, and runs a unit on one connection. Diffing, lowering and preconditions are the pure planner it embeds.\n\n## Functions\n\n```go\nfunc ExportHCL(ctx context.Context, q engine.Querier, opts ExportOptions) ([]planner.HCLFile, error)\n```\nExportHCL reads the tables of one schema and writes them as SQL Server HCL that the bundle evaluator reads back to the same tables (see planner.ExportHCL). Whatever the inspector could not read of a selected table (a refused table or member) fails the export, unless HCL.OmitUnsupported turns it into a comment line at the top of the output.\n\n## Types\n\n```go\ntype Dialect struct {\n\tplanner.Planner\n}\n```\nDialect is registered as \"sqlserver\".\n\n```go\nfunc (d Dialect) Capabilities(ctx context.Context, q engine.Querier) (engine.Capabilities, error)\n```\nCapabilities probes the database. Feature keys are the BackendCapability values, so the planner's FeatureTryConvert is the key of the same name. With q == nil it answers the planner's static, offline capabilities.\n\n```go\nfunc (d Dialect) Dependents(ctx context.Context, q engine.Querier, current migrate.Schema, columns []engine.ColumnRef) ([]engine.Dependent, error)\n```\nDependents lists what depends on columns. Without a database it derives the answer from current, as the pure planner does. With one it reads the catalog: everything SQL Server refuses to alter a column under, with the definition that re-creates it exactly, or a Refusal for what it cannot reproduce.\n\n```go\nfunc (Dialect) Exec(ctx context.Context, q engine.Querier, s engine.Statement) error\n```\nExec runs one statement of a plan in a nested batch.\n\n```go\nfunc (Dialect) Inspect(ctx context.Context, q engine.Querier, scope engine.Scope) (engine.Inspection, error)\n```\nInspect reads the schema. Complete mode reads every object of scope.Schemas. Declared mode reads exactly the scope's objects that exist, with the catalog narrowed to their names. What the native model cannot hold comes back as a refusal instead of failing the inspection, so an object nobody touches never blocks a plan.\n\n```go\nfunc (Dialect) Open(ctx context.Context, conn *sql.Conn, opts engine.SessionOptions) (engine.UnitSession, error)\n```\nOpen starts one unit on its connection: the transaction when the unit has one, the application lock, SET LOCK\\_TIMEOUT and SET XACT\\_ABORT ON. A zero lock timeout means no waiting, for the application lock and for blocked statements. Finish ends the transaction, releases the lock and puts the connection's settings back, so the pooled connection is clean.\n\n```go\nfunc (Dialect) Reconcile(_ context.Context, _ engine.Querier, current, desired migrate.Schema) (migrate.Schema, error)\n```\nReconcile rewrites desired so that what it leaves unset inherits the live value and what the server compares as equal is spelled like the live value. It touches nothing else: a real difference stays one. The rules:\n\n  - a column of a character type with no collation takes the live column's collation, and a collation that differs only in case takes the live spelling.\n\n```go\nfunc (Dialect) SameDependent(before, after engine.Dependent) (bool, error)\n```\nSameDependent judges a rebuilt dependent identical when what re-creates it is equal. Every definition is normalised where it is read, so a strict comparison is enough.\n\n```go\ntype ExportOptions struct {\n\tSchema string\n\t// Tables are the tables to export; empty exports every table of the schema.\n\tTables []string\n\t// HCL configures the writer. DatabaseCollation is read from the database.\n\tHCL planner.HCLOptions\n}\n```\nExportOptions select what ExportHCL reads and how it writes it.\n\n","path":"github.com/flanksource/sqlglot-go/database/migrate/dialect/sqlserver","name":"sqlserver","synopsis":"Package sqlserver is the database half of the SQL Server dialect of the schema engine: it reads capabilities, schemas and the live dependents of columns, and runs a unit on one connection.","isRedistributable":true}
