Skip to content

Commit 2bf1f53

Browse files
authored
Merge pull request #160 from bibhuty-did-this/bibhuty/fix/ignore-default-column-for-views
feat: ignore default column for views
2 parents 575c7e9 + 06afd2e commit 2bf1f53

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: src/pg/Db.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,16 @@ export default class Db {
102102
if (tableOptions.schema) return;
103103
const { table, verCol, joins } = tableOptions;
104104

105-
const tableSchema = (
105+
const tableInfoSchema = (
106106
await this.query(sqlTag`
107-
SELECT table_schema
107+
SELECT table_schema, table_type
108108
FROM information_schema.tables
109109
WHERE table_name = ${table}
110110
ORDER BY array_position(current_schemas(false)::text[], table_schema::text) ASC
111111
LIMIT 1`)
112-
).rows[0].table_schema;
112+
).rows[0];
113+
const tableSchema = tableInfoSchema.table_schema;
114+
const tableType = tableInfoSchema.table_type;
113115

114116
const types = (
115117
await this.query(sqlTag`
@@ -143,7 +145,7 @@ export default class Db {
143145
column_name = ${verCol}`)
144146
).rows[0].column_default;
145147

146-
if (!verDefault) {
148+
if (!verDefault && tableType !== 'VIEW') {
147149
throw Error(`pg.verCol_without_default ${verCol}`);
148150
}
149151

0 commit comments

Comments
 (0)