@sprucelabs/postgres-data-store 4.2.0 → 5.0.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/build/QueryBuilder.js +11 -4
- package/build/esm/QueryBuilder.js +11 -4
- package/package.json +3 -3
package/build/QueryBuilder.js
CHANGED
|
@@ -91,9 +91,9 @@ class QueryBuilder {
|
|
|
91
91
|
const sub = this.buildSetClause({
|
|
92
92
|
query: value,
|
|
93
93
|
startingCount: placeholderCount++,
|
|
94
|
-
placeholderTemplate:
|
|
94
|
+
placeholderTemplate: '"{{fieldName}}" || ARRAY[${{count}}]',
|
|
95
95
|
});
|
|
96
|
-
values.push(...sub.values
|
|
96
|
+
values.push(...sub.values);
|
|
97
97
|
set.push(...sub.set);
|
|
98
98
|
}
|
|
99
99
|
else if (isNull || value === undefined) {
|
|
@@ -167,7 +167,7 @@ class QueryBuilder {
|
|
|
167
167
|
fields.forEach((f) => {
|
|
168
168
|
values.push(this.fieldValueToSqlValue(record, f));
|
|
169
169
|
let placeholder = `$${++placeholderCount}`;
|
|
170
|
-
if (this.isValueObject(record[f])) {
|
|
170
|
+
if (this.isValueObject(record[f]) && !Array.isArray(record[f])) {
|
|
171
171
|
placeholder += `::json`;
|
|
172
172
|
}
|
|
173
173
|
placeholders.push(placeholder);
|
|
@@ -185,7 +185,14 @@ class QueryBuilder {
|
|
|
185
185
|
value = value.toString().replace(/\//g, '');
|
|
186
186
|
}
|
|
187
187
|
if (this.isValueObject(value)) {
|
|
188
|
-
|
|
188
|
+
if (Array.isArray(value)) {
|
|
189
|
+
//in postgres, an array is notaded like this {1,2,3}
|
|
190
|
+
value = JSON.stringify(value);
|
|
191
|
+
value = `{${value.substring(1, value.length - 1)}}`;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
value = JSON.stringify(value);
|
|
195
|
+
}
|
|
189
196
|
}
|
|
190
197
|
return value !== null && value !== void 0 ? value : null;
|
|
191
198
|
}
|
|
@@ -88,9 +88,9 @@ export default class QueryBuilder {
|
|
|
88
88
|
const sub = this.buildSetClause({
|
|
89
89
|
query: value,
|
|
90
90
|
startingCount: placeholderCount++,
|
|
91
|
-
placeholderTemplate:
|
|
91
|
+
placeholderTemplate: '"{{fieldName}}" || ARRAY[${{count}}]',
|
|
92
92
|
});
|
|
93
|
-
values.push(...sub.values
|
|
93
|
+
values.push(...sub.values);
|
|
94
94
|
set.push(...sub.set);
|
|
95
95
|
}
|
|
96
96
|
else if (isNull || value === undefined) {
|
|
@@ -164,7 +164,7 @@ export default class QueryBuilder {
|
|
|
164
164
|
fields.forEach((f) => {
|
|
165
165
|
values.push(this.fieldValueToSqlValue(record, f));
|
|
166
166
|
let placeholder = `$${++placeholderCount}`;
|
|
167
|
-
if (this.isValueObject(record[f])) {
|
|
167
|
+
if (this.isValueObject(record[f]) && !Array.isArray(record[f])) {
|
|
168
168
|
placeholder += `::json`;
|
|
169
169
|
}
|
|
170
170
|
placeholders.push(placeholder);
|
|
@@ -182,7 +182,14 @@ export default class QueryBuilder {
|
|
|
182
182
|
value = value.toString().replace(/\//g, '');
|
|
183
183
|
}
|
|
184
184
|
if (this.isValueObject(value)) {
|
|
185
|
-
|
|
185
|
+
if (Array.isArray(value)) {
|
|
186
|
+
//in postgres, an array is notaded like this {1,2,3}
|
|
187
|
+
value = JSON.stringify(value);
|
|
188
|
+
value = `{${value.substring(1, value.length - 1)}}`;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
value = JSON.stringify(value);
|
|
192
|
+
}
|
|
186
193
|
}
|
|
187
194
|
return value !== null && value !== void 0 ? value : null;
|
|
188
195
|
}
|
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"sprucebot",
|
|
23
23
|
"sprucelabs"
|
|
24
24
|
],
|
|
25
|
-
"version": "
|
|
25
|
+
"version": "5.0.1",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build.ci": "yarn build.tsc && yarn build.resolve-paths && yarn lint",
|
|
28
28
|
"build.dev": "yarn build.tsc --sourceMap ; yarn resolve-paths.lint",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"watch.tsc": "tsc -w"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@sprucelabs/data-stores": "^26.2.
|
|
55
|
-
"@sprucelabs/schema": "^29.
|
|
54
|
+
"@sprucelabs/data-stores": "^26.2.8",
|
|
55
|
+
"@sprucelabs/schema": "^29.3.0",
|
|
56
56
|
"pg": "^8.11.3"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|