MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestAlterTableStatement_SQL

Function TestAlterTableStatement_SQL

pkg/sql/ast/sql_coverage_test.go:42–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestAlterTableStatement_SQL(t *testing.T) {
43 stmt := &AlterTableStatement{
44 Table: "users",
45 Actions: []AlterTableAction{
46 {Type: "ADD COLUMN", ColumnDef: &ColumnDef{Name: "email", Type: "TEXT"}},
47 {Type: "DROP COLUMN", ColumnName: "old_col"},
48 {Type: "ADD CONSTRAINT", Constraint: &TableConstraint{Type: "UNIQUE", Columns: []string{"email"}}},
49 {Type: "RENAME TO new_table"},
50 },
51 }
52 sql := stmt.SQL()
53 for _, want := range []string{"ALTER TABLE users", "ADD COLUMN email TEXT", "DROP COLUMN old_col"} {
54 if !strings.Contains(sql, want) {
55 t.Errorf("SQL() missing %q, got: %s", want, sql)
56 }
57 }
58}
59
60func TestDropStatement_SQL(t *testing.T) {
61 stmt := &DropStatement{

Callers

nothing calls this directly

Calls 2

SQLMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected