@graffy/pg 0.16.15 → 0.16.18
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.
- package/index.cjs +14 -11
- package/index.mjs +14 -11
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -33,34 +33,35 @@ class Sql {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
get
|
|
36
|
+
get sql() {
|
|
37
37
|
const len = this.strings.length;
|
|
38
38
|
let i = 1;
|
|
39
39
|
let value = this.strings[0];
|
|
40
40
|
while (i < len)
|
|
41
|
-
value +=
|
|
41
|
+
value += `?${this.strings[i++]}`;
|
|
42
42
|
return value;
|
|
43
43
|
}
|
|
44
|
-
get
|
|
44
|
+
get statement() {
|
|
45
45
|
const len = this.strings.length;
|
|
46
46
|
let i = 1;
|
|
47
47
|
let value = this.strings[0];
|
|
48
48
|
while (i < len)
|
|
49
|
-
value +=
|
|
49
|
+
value += `:${i}${this.strings[i++]}`;
|
|
50
50
|
return value;
|
|
51
51
|
}
|
|
52
|
-
get
|
|
52
|
+
get text() {
|
|
53
53
|
const len = this.strings.length;
|
|
54
54
|
let i = 1;
|
|
55
55
|
let value = this.strings[0];
|
|
56
56
|
while (i < len)
|
|
57
|
-
value +=
|
|
57
|
+
value += `$${i}${this.strings[i++]}`;
|
|
58
58
|
return value;
|
|
59
59
|
}
|
|
60
60
|
inspect() {
|
|
61
61
|
return {
|
|
62
|
-
text: this.text,
|
|
63
62
|
sql: this.sql,
|
|
63
|
+
statement: this.statement,
|
|
64
|
+
text: this.text,
|
|
64
65
|
values: this.values
|
|
65
66
|
};
|
|
66
67
|
}
|
|
@@ -758,12 +759,14 @@ class Db {
|
|
|
758
759
|
if (tableOptions.schema)
|
|
759
760
|
return;
|
|
760
761
|
const { table, verCol, joins } = tableOptions;
|
|
761
|
-
const
|
|
762
|
-
SELECT table_schema
|
|
762
|
+
const tableInfoSchema = (await this.query(sql`
|
|
763
|
+
SELECT table_schema, table_type
|
|
763
764
|
FROM information_schema.tables
|
|
764
765
|
WHERE table_name = ${table}
|
|
765
766
|
ORDER BY array_position(current_schemas(false)::text[], table_schema::text) ASC
|
|
766
|
-
LIMIT 1`)).rows[0]
|
|
767
|
+
LIMIT 1`)).rows[0];
|
|
768
|
+
const tableSchema = tableInfoSchema.table_schema;
|
|
769
|
+
const tableType = tableInfoSchema.table_type;
|
|
767
770
|
const types2 = (await this.query(sql`
|
|
768
771
|
SELECT jsonb_object_agg(column_name, udt_name) AS column_types
|
|
769
772
|
FROM information_schema.columns
|
|
@@ -783,7 +786,7 @@ class Db {
|
|
|
783
786
|
table_name = ${table} AND
|
|
784
787
|
table_schema = ${tableSchema} AND
|
|
785
788
|
column_name = ${verCol}`)).rows[0].column_default;
|
|
786
|
-
if (!verDefault) {
|
|
789
|
+
if (!verDefault && tableType !== "VIEW") {
|
|
787
790
|
throw Error(`pg.verCol_without_default ${verCol}`);
|
|
788
791
|
}
|
|
789
792
|
await Promise.all(
|
package/index.mjs
CHANGED
|
@@ -31,34 +31,35 @@ class Sql {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
get
|
|
34
|
+
get sql() {
|
|
35
35
|
const len = this.strings.length;
|
|
36
36
|
let i = 1;
|
|
37
37
|
let value = this.strings[0];
|
|
38
38
|
while (i < len)
|
|
39
|
-
value +=
|
|
39
|
+
value += `?${this.strings[i++]}`;
|
|
40
40
|
return value;
|
|
41
41
|
}
|
|
42
|
-
get
|
|
42
|
+
get statement() {
|
|
43
43
|
const len = this.strings.length;
|
|
44
44
|
let i = 1;
|
|
45
45
|
let value = this.strings[0];
|
|
46
46
|
while (i < len)
|
|
47
|
-
value +=
|
|
47
|
+
value += `:${i}${this.strings[i++]}`;
|
|
48
48
|
return value;
|
|
49
49
|
}
|
|
50
|
-
get
|
|
50
|
+
get text() {
|
|
51
51
|
const len = this.strings.length;
|
|
52
52
|
let i = 1;
|
|
53
53
|
let value = this.strings[0];
|
|
54
54
|
while (i < len)
|
|
55
|
-
value +=
|
|
55
|
+
value += `$${i}${this.strings[i++]}`;
|
|
56
56
|
return value;
|
|
57
57
|
}
|
|
58
58
|
inspect() {
|
|
59
59
|
return {
|
|
60
|
-
text: this.text,
|
|
61
60
|
sql: this.sql,
|
|
61
|
+
statement: this.statement,
|
|
62
|
+
text: this.text,
|
|
62
63
|
values: this.values
|
|
63
64
|
};
|
|
64
65
|
}
|
|
@@ -756,12 +757,14 @@ class Db {
|
|
|
756
757
|
if (tableOptions.schema)
|
|
757
758
|
return;
|
|
758
759
|
const { table, verCol, joins } = tableOptions;
|
|
759
|
-
const
|
|
760
|
-
SELECT table_schema
|
|
760
|
+
const tableInfoSchema = (await this.query(sql`
|
|
761
|
+
SELECT table_schema, table_type
|
|
761
762
|
FROM information_schema.tables
|
|
762
763
|
WHERE table_name = ${table}
|
|
763
764
|
ORDER BY array_position(current_schemas(false)::text[], table_schema::text) ASC
|
|
764
|
-
LIMIT 1`)).rows[0]
|
|
765
|
+
LIMIT 1`)).rows[0];
|
|
766
|
+
const tableSchema = tableInfoSchema.table_schema;
|
|
767
|
+
const tableType = tableInfoSchema.table_type;
|
|
765
768
|
const types2 = (await this.query(sql`
|
|
766
769
|
SELECT jsonb_object_agg(column_name, udt_name) AS column_types
|
|
767
770
|
FROM information_schema.columns
|
|
@@ -781,7 +784,7 @@ class Db {
|
|
|
781
784
|
table_name = ${table} AND
|
|
782
785
|
table_schema = ${tableSchema} AND
|
|
783
786
|
column_name = ${verCol}`)).rows[0].column_default;
|
|
784
|
-
if (!verDefault) {
|
|
787
|
+
if (!verDefault && tableType !== "VIEW") {
|
|
785
788
|
throw Error(`pg.verCol_without_default ${verCol}`);
|
|
786
789
|
}
|
|
787
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.
|
|
5
|
+
"version": "0.16.18",
|
|
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.
|
|
19
|
+
"@graffy/common": "0.16.18",
|
|
20
20
|
"debug": "^4.3.3"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|