MCPcopy
hub / github.com/sqlc-dev/sqlc / TestUpdateErrors

Function TestUpdateErrors

internal/engine/postgresql/catalog_test.go:14–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestUpdateErrors(t *testing.T) {
15 p := NewParser()
16 for i, tc := range []struct {
17 stmt string
18 err *sqlerr.Error
19 }{
20 {
21 `
22 CREATE TABLE foo ();
23 CREATE TABLE foo ();
24 `,
25 sqlerr.RelationExists("foo"),
26 },
27 {
28 `
29 CREATE TYPE foo AS ENUM ('bar');
30 CREATE TYPE foo AS ENUM ('bar');
31 `,
32 sqlerr.TypeExists("foo"),
33 },
34 {
35 `
36 DROP TABLE foo;
37 `,
38 sqlerr.RelationNotFound("foo"),
39 },
40 {
41 `
42 DROP TYPE foo;
43 `,
44 sqlerr.TypeNotFound("foo"),
45 },
46 {
47 `
48 CREATE TABLE foo ();
49 CREATE TABLE bar ();
50 ALTER TABLE foo RENAME TO bar;
51 `,
52 sqlerr.RelationExists("bar"),
53 },
54 {
55 `
56 ALTER TABLE foo RENAME TO bar;
57 `,
58 sqlerr.RelationNotFound("foo"),
59 },
60 {
61 `
62 CREATE TABLE foo ();
63 ALTER TABLE foo ADD COLUMN bar text;
64 ALTER TABLE foo ADD COLUMN bar text;
65 `,
66 sqlerr.ColumnExists("foo", "bar"),
67 },
68 {
69 `
70 CREATE TABLE foo ();
71 ALTER TABLE foo DROP COLUMN bar;

Callers

nothing calls this directly

Calls 14

ParseMethod · 0.95
BuildMethod · 0.95
ErrorMethod · 0.95
RelationExistsFunction · 0.92
TypeExistsFunction · 0.92
RelationNotFoundFunction · 0.92
TypeNotFoundFunction · 0.92
ColumnExistsFunction · 0.92
ColumnNotFoundFunction · 0.92
SchemaExistsFunction · 0.92
SchemaNotFoundFunction · 0.92
LogMethod · 0.80

Tested by

no test coverage detected