| 179 | } |
| 180 | |
| 181 | func TestCreateTableStatementSQL(t *testing.T) { |
| 182 | stmt := &CreateTableStatement{ |
| 183 | Name: "users", |
| 184 | Columns: []ColumnDef{ |
| 185 | {Name: "id", Type: "INTEGER", Constraints: []ColumnConstraint{{Type: "PRIMARY KEY"}}}, |
| 186 | {Name: "name", Type: "VARCHAR(255)", Constraints: []ColumnConstraint{{Type: "NOT NULL"}}}, |
| 187 | {Name: "email", Type: "VARCHAR(255)", Constraints: []ColumnConstraint{{Type: "UNIQUE"}}}, |
| 188 | }, |
| 189 | } |
| 190 | want := "CREATE TABLE users (id INTEGER PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255) UNIQUE)" |
| 191 | if got := stmt.SQL(); got != want { |
| 192 | t.Errorf("SQL() =\n %s\nwant:\n %s", got, want) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | func TestExpressionSQL(t *testing.T) { |
| 197 | tests := []struct { |