@graffy/pg 0.16.16 → 0.16.19-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +6 -4
  2. package/index.mjs +6 -4
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -759,12 +759,14 @@ class Db {
759
759
  if (tableOptions.schema)
760
760
  return;
761
761
  const { table, verCol, joins } = tableOptions;
762
- const tableSchema = (await this.query(sql`
763
- SELECT table_schema
762
+ const tableInfoSchema = (await this.query(sql`
763
+ SELECT table_schema, table_type
764
764
  FROM information_schema.tables
765
765
  WHERE table_name = ${table}
766
766
  ORDER BY array_position(current_schemas(false)::text[], table_schema::text) ASC
767
- LIMIT 1`)).rows[0].table_schema;
767
+ LIMIT 1`)).rows[0];
768
+ const tableSchema = tableInfoSchema.table_schema;
769
+ const tableType = tableInfoSchema.table_type;
768
770
  const types2 = (await this.query(sql`
769
771
  SELECT jsonb_object_agg(column_name, udt_name) AS column_types
770
772
  FROM information_schema.columns
@@ -784,7 +786,7 @@ class Db {
784
786
  table_name = ${table} AND
785
787
  table_schema = ${tableSchema} AND
786
788
  column_name = ${verCol}`)).rows[0].column_default;
787
- if (!verDefault) {
789
+ if (!verDefault && tableType !== "VIEW") {
788
790
  throw Error(`pg.verCol_without_default ${verCol}`);
789
791
  }
790
792
  await Promise.all(
package/index.mjs CHANGED
@@ -757,12 +757,14 @@ class Db {
757
757
  if (tableOptions.schema)
758
758
  return;
759
759
  const { table, verCol, joins } = tableOptions;
760
- const tableSchema = (await this.query(sql`
761
- SELECT table_schema
760
+ const tableInfoSchema = (await this.query(sql`
761
+ SELECT table_schema, table_type
762
762
  FROM information_schema.tables
763
763
  WHERE table_name = ${table}
764
764
  ORDER BY array_position(current_schemas(false)::text[], table_schema::text) ASC
765
- LIMIT 1`)).rows[0].table_schema;
765
+ LIMIT 1`)).rows[0];
766
+ const tableSchema = tableInfoSchema.table_schema;
767
+ const tableType = tableInfoSchema.table_type;
766
768
  const types2 = (await this.query(sql`
767
769
  SELECT jsonb_object_agg(column_name, udt_name) AS column_types
768
770
  FROM information_schema.columns
@@ -782,7 +784,7 @@ class Db {
782
784
  table_name = ${table} AND
783
785
  table_schema = ${tableSchema} AND
784
786
  column_name = ${verCol}`)).rows[0].column_default;
785
- if (!verDefault) {
787
+ if (!verDefault && tableType !== "VIEW") {
786
788
  throw Error(`pg.verCol_without_default ${verCol}`);
787
789
  }
788
790
  await Promise.all(
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graffy/pg",
3
3
  "description": "The standard Postgres module for Graffy. Each instance this module mounts a Postgres table as a Graffy subtree.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.16.16",
5
+ "version": "0.16.19-alpha.1",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
- "@graffy/common": "0.16.16",
19
+ "@graffy/common": "0.16.19-alpha.1",
20
20
  "debug": "^4.3.3"
21
21
  },
22
22
  "peerDependencies": {