Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ignore default column for views #160

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/pg/Db.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ export default class Db {
if (tableOptions.schema) return;
const { table, verCol, joins } = tableOptions;

const tableSchema = (
const tableInfoSchema = (
await this.query(sqlTag`
SELECT table_schema
SELECT table_schema, table_type
FROM information_schema.tables
WHERE table_name = ${table}
ORDER BY array_position(current_schemas(false)::text[], table_schema::text) ASC
LIMIT 1`)
).rows[0].table_schema;
).rows[0];
const tableSchema = tableInfoSchema.table_schema;
const tableType = tableInfoSchema.table_type;

const types = (
await this.query(sqlTag`
Expand Down Expand Up @@ -141,7 +143,7 @@ export default class Db {
column_name = ${verCol}`)
).rows[0].column_default;

if (!verDefault) {
if (!verDefault && tableType !== 'VIEW') {
throw Error(`pg.verCol_without_default ${verCol}`);
}

Expand Down