relq 1.0.81 → 1.0.82
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/dist/cjs/core/helpers/ConnectedInsertBuilder.cjs +4 -1
- package/dist/cjs/core/helpers/ConnectedUpdateBuilder.cjs +4 -1
- package/dist/cjs/insert/insert-builder.cjs +13 -18
- package/dist/cjs/update/update-builder.cjs +4 -5
- package/dist/esm/core/helpers/ConnectedInsertBuilder.js +4 -1
- package/dist/esm/core/helpers/ConnectedUpdateBuilder.js +4 -1
- package/dist/esm/insert/insert-builder.js +13 -18
- package/dist/esm/update/update-builder.js +4 -5
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -36,10 +36,13 @@ class ConnectedInsertBuilder {
|
|
|
36
36
|
});
|
|
37
37
|
this.builder.setColumnTypeResolver((column) => {
|
|
38
38
|
const columnDef = tableColumns[column];
|
|
39
|
-
if (!columnDef
|
|
39
|
+
if (!columnDef) {
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
42
42
|
const type = columnDef.$type;
|
|
43
|
+
if (typeof type !== 'string') {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
43
46
|
const isArray = columnDef.$array === true;
|
|
44
47
|
const baseType = type.replace(/\[\]$/, '').toLowerCase();
|
|
45
48
|
return { type: baseType, isArray };
|
|
@@ -35,10 +35,13 @@ class ConnectedUpdateBuilder {
|
|
|
35
35
|
});
|
|
36
36
|
this.builder.setColumnTypeResolver((column) => {
|
|
37
37
|
const columnDef = tableColumns[column];
|
|
38
|
-
if (!columnDef
|
|
38
|
+
if (!columnDef) {
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
41
41
|
const type = columnDef.$type;
|
|
42
|
+
if (typeof type !== 'string') {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
42
45
|
const isArray = columnDef.$array === true;
|
|
43
46
|
const baseType = type.replace(/\[\]$/, '').toLowerCase();
|
|
44
47
|
return { type: baseType, isArray };
|
|
@@ -184,34 +184,29 @@ class InsertBuilder {
|
|
|
184
184
|
const placeholderTypes = [];
|
|
185
185
|
for (const colName of originalColumns) {
|
|
186
186
|
const value = row[colName];
|
|
187
|
-
if (Array.isArray(value)) {
|
|
187
|
+
if (Array.isArray(value) || (value !== null && typeof value === 'object' && !(value instanceof Date))) {
|
|
188
188
|
const typeInfo = this.columnTypeResolver?.(colName);
|
|
189
189
|
if (typeInfo) {
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
if (typeInfo.isArray) {
|
|
192
|
+
processedValues.push(this.formatPostgresArray(value, typeInfo.type));
|
|
193
|
+
}
|
|
194
|
+
else if (typeInfo.type === 'jsonb' || typeInfo.type === 'json') {
|
|
195
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
199
|
+
}
|
|
195
200
|
}
|
|
196
201
|
else {
|
|
197
|
-
processedValues.push(this.
|
|
202
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
205
|
else {
|
|
201
|
-
|
|
202
|
-
if (hasObjects) {
|
|
203
|
-
processedValues.push(this.formatJsonbValue(value));
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
processedValues.push(this.formatPostgresArray(value));
|
|
207
|
-
}
|
|
206
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
208
207
|
}
|
|
209
208
|
placeholderTypes.push('%s');
|
|
210
209
|
}
|
|
211
|
-
else if (value !== null && typeof value === 'object' && !(value instanceof Date)) {
|
|
212
|
-
processedValues.push(this.formatJsonbValue(value));
|
|
213
|
-
placeholderTypes.push('%s');
|
|
214
|
-
}
|
|
215
210
|
else {
|
|
216
211
|
processedValues.push(value);
|
|
217
212
|
placeholderTypes.push('%L');
|
|
@@ -172,12 +172,11 @@ class UpdateBuilder {
|
|
|
172
172
|
else if (typeInfo.type === 'jsonb' || typeInfo.type === 'json') {
|
|
173
173
|
return this.formatJsonbValue(value);
|
|
174
174
|
}
|
|
175
|
+
else {
|
|
176
|
+
return this.formatJsonbValue(value);
|
|
177
|
+
}
|
|
175
178
|
}
|
|
176
|
-
|
|
177
|
-
if (hasObjects) {
|
|
178
|
-
return this.formatJsonbValue(value);
|
|
179
|
-
}
|
|
180
|
-
return this.formatPostgresArray(value);
|
|
179
|
+
return this.formatJsonbValue(value);
|
|
181
180
|
}
|
|
182
181
|
toString() {
|
|
183
182
|
const processedPairs = Object.entries(this.updateData).map(([col, val]) => {
|
|
@@ -33,10 +33,13 @@ export class ConnectedInsertBuilder {
|
|
|
33
33
|
});
|
|
34
34
|
this.builder.setColumnTypeResolver((column) => {
|
|
35
35
|
const columnDef = tableColumns[column];
|
|
36
|
-
if (!columnDef
|
|
36
|
+
if (!columnDef) {
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
39
|
const type = columnDef.$type;
|
|
40
|
+
if (typeof type !== 'string') {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
40
43
|
const isArray = columnDef.$array === true;
|
|
41
44
|
const baseType = type.replace(/\[\]$/, '').toLowerCase();
|
|
42
45
|
return { type: baseType, isArray };
|
|
@@ -32,10 +32,13 @@ export class ConnectedUpdateBuilder {
|
|
|
32
32
|
});
|
|
33
33
|
this.builder.setColumnTypeResolver((column) => {
|
|
34
34
|
const columnDef = tableColumns[column];
|
|
35
|
-
if (!columnDef
|
|
35
|
+
if (!columnDef) {
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
38
|
const type = columnDef.$type;
|
|
39
|
+
if (typeof type !== 'string') {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
39
42
|
const isArray = columnDef.$array === true;
|
|
40
43
|
const baseType = type.replace(/\[\]$/, '').toLowerCase();
|
|
41
44
|
return { type: baseType, isArray };
|
|
@@ -178,34 +178,29 @@ export class InsertBuilder {
|
|
|
178
178
|
const placeholderTypes = [];
|
|
179
179
|
for (const colName of originalColumns) {
|
|
180
180
|
const value = row[colName];
|
|
181
|
-
if (Array.isArray(value)) {
|
|
181
|
+
if (Array.isArray(value) || (value !== null && typeof value === 'object' && !(value instanceof Date))) {
|
|
182
182
|
const typeInfo = this.columnTypeResolver?.(colName);
|
|
183
183
|
if (typeInfo) {
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
if (Array.isArray(value)) {
|
|
185
|
+
if (typeInfo.isArray) {
|
|
186
|
+
processedValues.push(this.formatPostgresArray(value, typeInfo.type));
|
|
187
|
+
}
|
|
188
|
+
else if (typeInfo.type === 'jsonb' || typeInfo.type === 'json') {
|
|
189
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
193
|
+
}
|
|
189
194
|
}
|
|
190
195
|
else {
|
|
191
|
-
processedValues.push(this.
|
|
196
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
192
197
|
}
|
|
193
198
|
}
|
|
194
199
|
else {
|
|
195
|
-
|
|
196
|
-
if (hasObjects) {
|
|
197
|
-
processedValues.push(this.formatJsonbValue(value));
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
processedValues.push(this.formatPostgresArray(value));
|
|
201
|
-
}
|
|
200
|
+
processedValues.push(this.formatJsonbValue(value));
|
|
202
201
|
}
|
|
203
202
|
placeholderTypes.push('%s');
|
|
204
203
|
}
|
|
205
|
-
else if (value !== null && typeof value === 'object' && !(value instanceof Date)) {
|
|
206
|
-
processedValues.push(this.formatJsonbValue(value));
|
|
207
|
-
placeholderTypes.push('%s');
|
|
208
|
-
}
|
|
209
204
|
else {
|
|
210
205
|
processedValues.push(value);
|
|
211
206
|
placeholderTypes.push('%L');
|
|
@@ -166,12 +166,11 @@ export class UpdateBuilder {
|
|
|
166
166
|
else if (typeInfo.type === 'jsonb' || typeInfo.type === 'json') {
|
|
167
167
|
return this.formatJsonbValue(value);
|
|
168
168
|
}
|
|
169
|
+
else {
|
|
170
|
+
return this.formatJsonbValue(value);
|
|
171
|
+
}
|
|
169
172
|
}
|
|
170
|
-
|
|
171
|
-
if (hasObjects) {
|
|
172
|
-
return this.formatJsonbValue(value);
|
|
173
|
-
}
|
|
174
|
-
return this.formatPostgresArray(value);
|
|
173
|
+
return this.formatJsonbValue(value);
|
|
175
174
|
}
|
|
176
175
|
toString() {
|
|
177
176
|
const processedPairs = Object.entries(this.updateData).map(([col, val]) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -2501,8 +2501,8 @@ export declare class UpdateBuilder {
|
|
|
2501
2501
|
*/
|
|
2502
2502
|
private formatJsonbValue;
|
|
2503
2503
|
/**
|
|
2504
|
-
* Format an array value using schema type info
|
|
2505
|
-
*
|
|
2504
|
+
* Format an array value using schema type info.
|
|
2505
|
+
* Schema is required for proper handling - defaults to JSONB if no schema.
|
|
2506
2506
|
*/
|
|
2507
2507
|
private formatArrayValueWithType;
|
|
2508
2508
|
toString(): string;
|