@graffy/pg 0.16.21-alpha.2 → 0.17.1-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.
- package/index.cjs +18 -18
- package/index.mjs +18 -18
- package/package.json +4 -4
package/index.cjs
CHANGED
|
@@ -85,14 +85,14 @@ function formatSql(sql2) {
|
|
|
85
85
|
const values = sql2.values.slice(0);
|
|
86
86
|
const output = [];
|
|
87
87
|
while (strings.length) {
|
|
88
|
-
output.push(strings.shift()
|
|
88
|
+
output.push(strings.shift());
|
|
89
89
|
if (!values.length) break;
|
|
90
90
|
const value = values.shift();
|
|
91
91
|
output.push(
|
|
92
|
-
typeof value === "number" ? value.toString() : typeof value === "object" ? `'${JSON.stringify(value)}'` : `'${value}'`
|
|
92
|
+
typeof value === "number" ? value.toString() : value === null ? "null" : typeof value === "object" ? `'${JSON.stringify(value)}'` : `'${value}'`
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
|
-
return sqlFormatter.format(output.join("")
|
|
95
|
+
return sqlFormatter.format(output.join(""), { language: "postgresql" });
|
|
96
96
|
}
|
|
97
97
|
const getJsonBuildTrusted = (variadic) => {
|
|
98
98
|
const args = join(
|
|
@@ -172,23 +172,23 @@ const getSelectCols = (options, projection = null) => {
|
|
|
172
172
|
sqls.push(
|
|
173
173
|
sql`jsonb_build_object(${join(subSqls, ", ")}) AS "${raw(key)}"`
|
|
174
174
|
);
|
|
175
|
-
}
|
|
176
|
-
if (key[0] === "$") continue;
|
|
177
|
-
if (typeof projection[key] === "object") {
|
|
178
|
-
const optimisedJsonBuild = getOptimisedJsonBuild(
|
|
179
|
-
projection[key],
|
|
180
|
-
[],
|
|
181
|
-
key,
|
|
182
|
-
options
|
|
183
|
-
);
|
|
184
|
-
sqls.push(
|
|
185
|
-
sql`jsonb_build_object(${join(optimisedJsonBuild, ", ")}) AS "${raw(key)}"`
|
|
186
|
-
);
|
|
187
175
|
} else {
|
|
188
|
-
|
|
176
|
+
if (typeof projection[key] === "object") {
|
|
177
|
+
const optimisedJsonBuild = getOptimisedJsonBuild(
|
|
178
|
+
projection[key],
|
|
179
|
+
[],
|
|
180
|
+
key,
|
|
181
|
+
options
|
|
182
|
+
);
|
|
183
|
+
sqls.push(
|
|
184
|
+
sql`jsonb_build_object(${join(optimisedJsonBuild, ", ")}) AS "${raw(key)}"`
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
sqls.push(sql`"${raw(key)}"`);
|
|
188
|
+
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
return
|
|
191
|
+
return join(sqls, ", ");
|
|
192
192
|
};
|
|
193
193
|
function vertexSql(array, nullValue) {
|
|
194
194
|
return sql`array[${join(
|
|
@@ -410,7 +410,7 @@ function simplify(node) {
|
|
|
410
410
|
if (op === "$or") {
|
|
411
411
|
const { eqmap, noneq, change } = node[1].reduce(
|
|
412
412
|
(acc, item) => {
|
|
413
|
-
if (item[0] !== "$eq") {
|
|
413
|
+
if (item[0] !== "$eq" || item[2] === null) {
|
|
414
414
|
acc.noneq.push(item);
|
|
415
415
|
} else if (acc.eqmap[item[1]]) {
|
|
416
416
|
acc.change = true;
|
package/index.mjs
CHANGED
|
@@ -83,14 +83,14 @@ function formatSql(sql2) {
|
|
|
83
83
|
const values = sql2.values.slice(0);
|
|
84
84
|
const output = [];
|
|
85
85
|
while (strings.length) {
|
|
86
|
-
output.push(strings.shift()
|
|
86
|
+
output.push(strings.shift());
|
|
87
87
|
if (!values.length) break;
|
|
88
88
|
const value = values.shift();
|
|
89
89
|
output.push(
|
|
90
|
-
typeof value === "number" ? value.toString() : typeof value === "object" ? `'${JSON.stringify(value)}'` : `'${value}'`
|
|
90
|
+
typeof value === "number" ? value.toString() : value === null ? "null" : typeof value === "object" ? `'${JSON.stringify(value)}'` : `'${value}'`
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
|
-
return format(output.join("")
|
|
93
|
+
return format(output.join(""), { language: "postgresql" });
|
|
94
94
|
}
|
|
95
95
|
const getJsonBuildTrusted = (variadic) => {
|
|
96
96
|
const args = join(
|
|
@@ -170,23 +170,23 @@ const getSelectCols = (options, projection = null) => {
|
|
|
170
170
|
sqls.push(
|
|
171
171
|
sql`jsonb_build_object(${join(subSqls, ", ")}) AS "${raw(key)}"`
|
|
172
172
|
);
|
|
173
|
-
}
|
|
174
|
-
if (key[0] === "$") continue;
|
|
175
|
-
if (typeof projection[key] === "object") {
|
|
176
|
-
const optimisedJsonBuild = getOptimisedJsonBuild(
|
|
177
|
-
projection[key],
|
|
178
|
-
[],
|
|
179
|
-
key,
|
|
180
|
-
options
|
|
181
|
-
);
|
|
182
|
-
sqls.push(
|
|
183
|
-
sql`jsonb_build_object(${join(optimisedJsonBuild, ", ")}) AS "${raw(key)}"`
|
|
184
|
-
);
|
|
185
173
|
} else {
|
|
186
|
-
|
|
174
|
+
if (typeof projection[key] === "object") {
|
|
175
|
+
const optimisedJsonBuild = getOptimisedJsonBuild(
|
|
176
|
+
projection[key],
|
|
177
|
+
[],
|
|
178
|
+
key,
|
|
179
|
+
options
|
|
180
|
+
);
|
|
181
|
+
sqls.push(
|
|
182
|
+
sql`jsonb_build_object(${join(optimisedJsonBuild, ", ")}) AS "${raw(key)}"`
|
|
183
|
+
);
|
|
184
|
+
} else {
|
|
185
|
+
sqls.push(sql`"${raw(key)}"`);
|
|
186
|
+
}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
return
|
|
189
|
+
return join(sqls, ", ");
|
|
190
190
|
};
|
|
191
191
|
function vertexSql(array, nullValue) {
|
|
192
192
|
return sql`array[${join(
|
|
@@ -408,7 +408,7 @@ function simplify(node) {
|
|
|
408
408
|
if (op === "$or") {
|
|
409
409
|
const { eqmap, noneq, change } = node[1].reduce(
|
|
410
410
|
(acc, item) => {
|
|
411
|
-
if (item[0] !== "$eq") {
|
|
411
|
+
if (item[0] !== "$eq" || item[2] === null) {
|
|
412
412
|
acc.noneq.push(item);
|
|
413
413
|
} else if (acc.eqmap[item[1]]) {
|
|
414
414
|
acc.change = true;
|
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.
|
|
5
|
+
"version": "0.17.1-alpha.1",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graffy/common": "0.
|
|
20
|
-
"debug": "^4.
|
|
21
|
-
"sql-formatter": "^15.6.
|
|
19
|
+
"@graffy/common": "0.17.1-alpha.1",
|
|
20
|
+
"debug": "^4.4.1",
|
|
21
|
+
"sql-formatter": "^15.6.4"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"pg": "^8.0.0"
|