(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestCreateTable(t *testing.T) { |
| 25 | RunScripts(t, []ScriptTest{ |
| 26 | { |
| 27 | // https://github.com/dolthub/doltgresql/issues/2580 |
| 28 | Name: "create table with UTF8 identifiers", |
| 29 | Assertions: []ScriptTestAssertion{ |
| 30 | { |
| 31 | Query: `CREATE TABLE foo😏(data🍆 TEXT);`, |
| 32 | Expected: []sql.Row{}, |
| 33 | }, |
| 34 | { |
| 35 | Query: `CREATE INDEX idx🍤 ON foo😏(data🍆);`, |
| 36 | Expected: []sql.Row{}, |
| 37 | }, |
| 38 | { |
| 39 | Query: `Insert into foo😏 (data🍆) VALUES ('foo');`, |
| 40 | Expected: []sql.Row{}, |
| 41 | }, |
| 42 | { |
| 43 | Query: `SELECT data🍆 FROM foo😏;`, |
| 44 | Expected: []sql.Row{{"foo"}}, |
| 45 | }, |
| 46 | }, |
| 47 | }, |
| 48 | { |
| 49 | Name: "create table with primary key", |
| 50 | Assertions: []ScriptTestAssertion{ |
| 51 | { |
| 52 | // TODO: we don't currently have a way to check for warnings in these tests, but this query was incorrectly |
| 53 | // producing a warning. Would be nice to assert no warnings on most queries. |
| 54 | Query: "create table employees (" + |
| 55 | " id int8," + |
| 56 | " last_name text," + |
| 57 | " first_name text," + |
| 58 | " primary key(id));", |
| 59 | }, |
| 60 | { |
| 61 | Query: "insert into employees (id, last_name, first_name) values (1, 'Doe', 'John');", |
| 62 | }, |
| 63 | { |
| 64 | Query: "select * from employees;", |
| 65 | Expected: []sql.Row{ |
| 66 | {1, "Doe", "John"}, |
| 67 | }, |
| 68 | }, |
| 69 | { |
| 70 | // Test that the PK constraint shows up in the information schema |
| 71 | Query: "SELECT conname FROM pg_constraint WHERE conrelid = 'employees'::regclass AND contype = 'p';", |
| 72 | Expected: []sql.Row{{"employees_pkey"}}, |
| 73 | }, |
| 74 | { |
| 75 | Query: "ALTER TABLE employees DROP CONSTRAINT employees_pkey;", |
| 76 | Expected: []sql.Row{}, |
| 77 | }, |
| 78 | }, |
| 79 | }, |
| 80 | { |
| 81 | // TODO: We don't currently support storing a custom name for a primary key constraint. |
nothing calls this directly
no test coverage detected