You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: testing/go/pgcatalog_test.go
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -279,6 +279,35 @@ order by 1,2;`,
279
279
})
280
280
}
281
281
282
+
funcTestPgAttributeViewColumns(t*testing.T) {
283
+
RunScripts(t, []ScriptTest{
284
+
{
285
+
Name: "pg_attribute includes view columns",
286
+
SetUpScript: []string{
287
+
`CREATE TABLE t (k int);`,
288
+
`CREATE VIEW v AS SELECT * FROM t;`,
289
+
},
290
+
Assertions: []ScriptTestAssertion{
291
+
{
292
+
// View columns should appear in pg_attribute, just like table columns.
293
+
Query: `SELECT c.relname, a.attname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid=c.oid WHERE c.relname IN ('t','v') ORDER BY c.relname, a.attnum;`,
294
+
Expected: []sql.Row{
295
+
{"t", "k"},
296
+
{"v", "k"},
297
+
},
298
+
},
299
+
{
300
+
// The view column's atttypid should match the underlying table column's type (int4 = 23).
301
+
Query: `SELECT a.attname, a.atttypid FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid=c.oid WHERE c.relname = 'v' ORDER BY a.attnum;`,
0 commit comments