MCPcopy
hub / github.com/sqldef/sqldef / TestBuildExportTableDDLCanonicalPrimaryKey

Function TestBuildExportTableDDLCanonicalPrimaryKey

database/mssql/database_test.go:24–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestBuildExportTableDDLCanonicalPrimaryKey(t *testing.T) {
25 db := &MssqlDatabase{}
26 db.SetGeneratorConfig(database.GeneratorConfig{LegacyIgnoreQuotes: false})
27
28 ddl := db.buildExportTableDDL(
29 "dbo.SystemUser",
30 []column{
31 {Name: "SystemUserId", dataType: "int", Nullable: false},
32 {Name: "Date", dataType: "date", Nullable: false},
33 },
34 []*indexDef{
35 {
36 name: "PK_SystemUser",
37 columns: []string{"[SystemUserId]"},
38 primary: true,
39 constraint: true,
40 indexType: "CLUSTERED",
41 },
42 },
43 nil,
44 nil,
45 )
46
47 if !strings.Contains(ddl, "CONSTRAINT [PK_SystemUser] PRIMARY KEY CLUSTERED ([SystemUserId])") {
48 t.Fatalf("expected canonical bracketed PK constraint and column in export, got:\n%s", ddl)
49 }
50 if !strings.Contains(ddl, "[Date] date NOT NULL") {
51 t.Fatalf("expected reserved identifier to remain bracketed in export, got:\n%s", ddl)
52 }
53}

Callers

nothing calls this directly

Calls 3

SetGeneratorConfigMethod · 0.95
buildExportTableDDLMethod · 0.95
FatalfMethod · 0.65

Tested by

no test coverage detected