| 40 | } |
| 41 | |
| 42 | func 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 | |
| 60 | func TestDropStatement_SQL(t *testing.T) { |
| 61 | stmt := &DropStatement{ |