pqb 0.3.9 → 0.4.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/dist/index.d.ts +104 -84
- package/dist/index.esm.js +150 -121
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +150 -121
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/columnSchema/columnType.test.ts +1 -1
- package/src/db.test.ts +2 -2
- package/src/db.ts +9 -1
- package/src/errors.test.ts +79 -0
- package/src/errors.ts +43 -5
- package/src/query.ts +6 -0
- package/src/queryMethods/aggregate.test.ts +11 -11
- package/src/queryMethods/aggregate.ts +5 -3
- package/src/queryMethods/callbacks.test.ts +6 -6
- package/src/queryMethods/callbacks.ts +8 -8
- package/src/queryMethods/columnInfo.ts +13 -19
- package/src/queryMethods/{insert.test.ts → create.test.ts} +106 -98
- package/src/queryMethods/{insert.ts → create.ts} +129 -113
- package/src/queryMethods/delete.test.ts +2 -2
- package/src/queryMethods/get.test.ts +2 -2
- package/src/queryMethods/index.ts +1 -1
- package/src/queryMethods/json.test.ts +1 -1
- package/src/queryMethods/log.test.ts +29 -8
- package/src/queryMethods/merge.test.ts +3 -3
- package/src/queryMethods/queryMethods.test.ts +4 -4
- package/src/queryMethods/queryMethods.ts +3 -3
- package/src/queryMethods/select.test.ts +7 -7
- package/src/queryMethods/then.test.ts +1 -73
- package/src/queryMethods/then.ts +8 -7
- package/src/queryMethods/update.test.ts +8 -8
- package/src/queryMethods/update.ts +7 -7
- package/src/queryMethods/upsert.ts +3 -3
- package/src/queryMethods/window.test.ts +2 -2
- package/src/sql/insert.ts +31 -19
- package/src/sql/types.ts +3 -2
- package/src/test-utils.ts +4 -1
package/dist/index.esm.js
CHANGED
|
@@ -791,8 +791,9 @@ class QueryError extends DatabaseError {
|
|
|
791
791
|
if (this.detail) {
|
|
792
792
|
const list = (_a = this.detail.match(/\((.*)\)=/)) == null ? void 0 : _a[1];
|
|
793
793
|
if (list) {
|
|
794
|
-
list.split(", ").forEach((
|
|
795
|
-
|
|
794
|
+
list.split(", ").forEach((item) => {
|
|
795
|
+
const column = item.startsWith('"') ? item.slice(1, -1) : item;
|
|
796
|
+
columns[column] = true;
|
|
796
797
|
});
|
|
797
798
|
}
|
|
798
799
|
}
|
|
@@ -1116,15 +1117,49 @@ const getFrom = (model, query, values) => {
|
|
|
1116
1117
|
return quoteSchemaAndTable(query.schema, model.table);
|
|
1117
1118
|
};
|
|
1118
1119
|
|
|
1120
|
+
const pushQueryArray = (q, key, value) => {
|
|
1121
|
+
if (!q.query[key])
|
|
1122
|
+
q.query[key] = value;
|
|
1123
|
+
else
|
|
1124
|
+
q.query[key].push(
|
|
1125
|
+
...value
|
|
1126
|
+
);
|
|
1127
|
+
return q;
|
|
1128
|
+
};
|
|
1129
|
+
const pushQueryValue = (q, key, value) => {
|
|
1130
|
+
pushOrNewArrayToObject(
|
|
1131
|
+
q.query,
|
|
1132
|
+
key,
|
|
1133
|
+
value
|
|
1134
|
+
);
|
|
1135
|
+
return q;
|
|
1136
|
+
};
|
|
1137
|
+
const setQueryObjectValue = (q, object, key, value) => {
|
|
1138
|
+
if (!q.query[object])
|
|
1139
|
+
q.query[object] = {
|
|
1140
|
+
[key]: value
|
|
1141
|
+
};
|
|
1142
|
+
else
|
|
1143
|
+
q.query[object][key] = value;
|
|
1144
|
+
return q;
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1119
1147
|
const pushInsertSql = (ctx, model, query, quotedAs) => {
|
|
1120
1148
|
const quotedColumns = query.columns.map(q);
|
|
1121
|
-
ctx.sql.push(
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1149
|
+
ctx.sql.push(`INSERT INTO ${quotedAs}(${quotedColumns.join(", ")})`);
|
|
1150
|
+
if (query.fromQuery) {
|
|
1151
|
+
const q2 = query.fromQuery.clone();
|
|
1152
|
+
pushQueryValue(
|
|
1153
|
+
q2,
|
|
1154
|
+
"select",
|
|
1155
|
+
isRaw(query.values) ? query.values : raw(encodeRow(ctx, query.values[0]))
|
|
1156
|
+
);
|
|
1157
|
+
ctx.sql.push(q2.toSql({ values: ctx.values }).text);
|
|
1158
|
+
} else {
|
|
1159
|
+
ctx.sql.push(
|
|
1160
|
+
`VALUES ${isRaw(query.values) ? getRaw(query.values, ctx.values) : query.values.map((row) => `(${encodeRow(ctx, row)})`).join(", ")}`
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1128
1163
|
if (query.onConflict) {
|
|
1129
1164
|
ctx.sql.push("ON CONFLICT");
|
|
1130
1165
|
const { expr, type } = query.onConflict;
|
|
@@ -1167,6 +1202,11 @@ const pushInsertSql = (ctx, model, query, quotedAs) => {
|
|
|
1167
1202
|
pushWhereStatementSql(ctx, model, query, quotedAs);
|
|
1168
1203
|
pushReturningSql(ctx, model, query, quotedAs);
|
|
1169
1204
|
};
|
|
1205
|
+
const encodeRow = (ctx, row) => {
|
|
1206
|
+
return row.map(
|
|
1207
|
+
(value) => value === void 0 ? "DEFAULT" : addValue(ctx.values, value)
|
|
1208
|
+
).join(", ");
|
|
1209
|
+
};
|
|
1170
1210
|
const pushReturningSql = (ctx, model, query, quotedAs) => {
|
|
1171
1211
|
if (query.select) {
|
|
1172
1212
|
ctx.sql.push(`RETURNING ${selectToSql(ctx, model, query, quotedAs)}`);
|
|
@@ -3140,33 +3180,6 @@ class TransactionAdapter {
|
|
|
3140
3180
|
}
|
|
3141
3181
|
}
|
|
3142
3182
|
|
|
3143
|
-
const pushQueryArray = (q, key, value) => {
|
|
3144
|
-
if (!q.query[key])
|
|
3145
|
-
q.query[key] = value;
|
|
3146
|
-
else
|
|
3147
|
-
q.query[key].push(
|
|
3148
|
-
...value
|
|
3149
|
-
);
|
|
3150
|
-
return q;
|
|
3151
|
-
};
|
|
3152
|
-
const pushQueryValue = (q, key, value) => {
|
|
3153
|
-
pushOrNewArrayToObject(
|
|
3154
|
-
q.query,
|
|
3155
|
-
key,
|
|
3156
|
-
value
|
|
3157
|
-
);
|
|
3158
|
-
return q;
|
|
3159
|
-
};
|
|
3160
|
-
const setQueryObjectValue = (q, object, key, value) => {
|
|
3161
|
-
if (!q.query[object])
|
|
3162
|
-
q.query[object] = {
|
|
3163
|
-
[key]: value
|
|
3164
|
-
};
|
|
3165
|
-
else
|
|
3166
|
-
q.query[object][key] = value;
|
|
3167
|
-
return q;
|
|
3168
|
-
};
|
|
3169
|
-
|
|
3170
3183
|
const getValueKey = Symbol("get");
|
|
3171
3184
|
const _get = (q, returnType, arg) => {
|
|
3172
3185
|
q.query.returnType = returnType;
|
|
@@ -3214,7 +3227,7 @@ const queryMethodByReturnType = {
|
|
|
3214
3227
|
let queryError = void 0;
|
|
3215
3228
|
class Then {
|
|
3216
3229
|
get then() {
|
|
3217
|
-
queryError = new
|
|
3230
|
+
queryError = new Error();
|
|
3218
3231
|
return maybeWrappedThen;
|
|
3219
3232
|
}
|
|
3220
3233
|
async catch(fn) {
|
|
@@ -3238,8 +3251,8 @@ const then = async (q, resolve, reject) => {
|
|
|
3238
3251
|
let beforeCallbacks;
|
|
3239
3252
|
let afterCallbacks;
|
|
3240
3253
|
if (q.query.type === "insert") {
|
|
3241
|
-
beforeCallbacks = q.query.
|
|
3242
|
-
afterCallbacks = q.query.
|
|
3254
|
+
beforeCallbacks = q.query.beforeCreate;
|
|
3255
|
+
afterCallbacks = q.query.afterCreate;
|
|
3243
3256
|
} else if (q.query.type === "update") {
|
|
3244
3257
|
beforeCallbacks = q.query.beforeUpdate;
|
|
3245
3258
|
afterCallbacks = q.query.afterUpdate;
|
|
@@ -3271,14 +3284,16 @@ const then = async (q, resolve, reject) => {
|
|
|
3271
3284
|
}
|
|
3272
3285
|
resolve == null ? void 0 : resolve(result);
|
|
3273
3286
|
} catch (err) {
|
|
3274
|
-
const error = err instanceof DatabaseError ? assignError(
|
|
3287
|
+
const error = err instanceof DatabaseError ? assignError(q, err) : err;
|
|
3275
3288
|
if (q.query.log && sql && logData) {
|
|
3276
3289
|
q.query.log.onError(error, sql, logData);
|
|
3277
3290
|
}
|
|
3278
3291
|
reject == null ? void 0 : reject(error);
|
|
3279
3292
|
}
|
|
3280
3293
|
};
|
|
3281
|
-
const assignError = (
|
|
3294
|
+
const assignError = (q, from) => {
|
|
3295
|
+
const to = new q.error();
|
|
3296
|
+
to.stack = queryError.stack;
|
|
3282
3297
|
to.message = from.message;
|
|
3283
3298
|
to.length = from.length;
|
|
3284
3299
|
to.name = from.name;
|
|
@@ -3598,7 +3613,9 @@ class Aggregate {
|
|
|
3598
3613
|
return this.clone()._count(arg, options);
|
|
3599
3614
|
}
|
|
3600
3615
|
_count(arg = "*", options) {
|
|
3601
|
-
return get(
|
|
3616
|
+
return get(
|
|
3617
|
+
this._selectCount(arg, options)
|
|
3618
|
+
);
|
|
3602
3619
|
}
|
|
3603
3620
|
selectCount(arg, options) {
|
|
3604
3621
|
return this.clone()._selectCount(arg, options);
|
|
@@ -3844,17 +3861,17 @@ class QueryCallbacks {
|
|
|
3844
3861
|
_afterQuery(cb) {
|
|
3845
3862
|
return pushQueryValue(this, "afterQuery", cb);
|
|
3846
3863
|
}
|
|
3847
|
-
|
|
3848
|
-
return this.clone().
|
|
3864
|
+
beforeCreate(cb) {
|
|
3865
|
+
return this.clone()._beforeCreate(cb);
|
|
3849
3866
|
}
|
|
3850
|
-
|
|
3851
|
-
return pushQueryValue(this, "
|
|
3867
|
+
_beforeCreate(cb) {
|
|
3868
|
+
return pushQueryValue(this, "beforeCreate", cb);
|
|
3852
3869
|
}
|
|
3853
|
-
|
|
3854
|
-
return this.clone().
|
|
3870
|
+
afterCreate(cb) {
|
|
3871
|
+
return this.clone()._afterCreate(cb);
|
|
3855
3872
|
}
|
|
3856
|
-
|
|
3857
|
-
return pushQueryValue(this, "
|
|
3873
|
+
_afterCreate(cb) {
|
|
3874
|
+
return pushQueryValue(this, "afterCreate", cb);
|
|
3858
3875
|
}
|
|
3859
3876
|
beforeUpdate(cb) {
|
|
3860
3877
|
return this.clone()._beforeUpdate(cb);
|
|
@@ -3937,22 +3954,16 @@ class ColumnInfoMethods {
|
|
|
3937
3954
|
if (column) {
|
|
3938
3955
|
this.query.column = column;
|
|
3939
3956
|
}
|
|
3940
|
-
this.
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
});
|
|
3951
|
-
resolve == null ? void 0 : resolve(info);
|
|
3952
|
-
}
|
|
3953
|
-
},
|
|
3954
|
-
reject
|
|
3955
|
-
);
|
|
3957
|
+
this.query.handleResult = async (_, result) => {
|
|
3958
|
+
if (column) {
|
|
3959
|
+
return rowToColumnInfo(result.rows[0]);
|
|
3960
|
+
} else {
|
|
3961
|
+
const info = {};
|
|
3962
|
+
result.rows.forEach((row) => {
|
|
3963
|
+
info[row.column_name] = rowToColumnInfo(row);
|
|
3964
|
+
});
|
|
3965
|
+
return info;
|
|
3966
|
+
}
|
|
3956
3967
|
};
|
|
3957
3968
|
return this;
|
|
3958
3969
|
}
|
|
@@ -4150,7 +4161,17 @@ var __spreadValues$4 = (a, b) => {
|
|
|
4150
4161
|
}
|
|
4151
4162
|
return a;
|
|
4152
4163
|
};
|
|
4153
|
-
const
|
|
4164
|
+
const handleSelect = (q) => {
|
|
4165
|
+
var _a;
|
|
4166
|
+
const select = (_a = q.query.select) == null ? void 0 : _a[0];
|
|
4167
|
+
const isCount = typeof select === "object" && "function" in select && select.function === "count";
|
|
4168
|
+
if (isCount) {
|
|
4169
|
+
q.query.select = void 0;
|
|
4170
|
+
} else if (isCount || !q.query.select) {
|
|
4171
|
+
q.query.select = ["*"];
|
|
4172
|
+
}
|
|
4173
|
+
};
|
|
4174
|
+
const processCreateItem = (item, rowIndex, ctx, columns, columnsMap) => {
|
|
4154
4175
|
Object.keys(item).forEach((key) => {
|
|
4155
4176
|
if (ctx.relations[key]) {
|
|
4156
4177
|
if (ctx.relations[key].type === "belongsTo") {
|
|
@@ -4182,13 +4203,13 @@ const processInsertItem = (item, rowIndex, ctx, columns, columnsMap) => {
|
|
|
4182
4203
|
}
|
|
4183
4204
|
});
|
|
4184
4205
|
};
|
|
4185
|
-
const
|
|
4206
|
+
const createCtx = (q) => ({
|
|
4186
4207
|
prependRelations: {},
|
|
4187
4208
|
appendRelations: {},
|
|
4188
4209
|
requiredReturning: {},
|
|
4189
4210
|
relations: q.relations
|
|
4190
4211
|
});
|
|
4191
|
-
const
|
|
4212
|
+
const getSingleReturnType = (q) => {
|
|
4192
4213
|
const { select, returnType = "all" } = q.query;
|
|
4193
4214
|
if (select) {
|
|
4194
4215
|
return returnType === "all" ? "one" : returnType;
|
|
@@ -4196,7 +4217,7 @@ const getInsertSingleReturnType = (q) => {
|
|
|
4196
4217
|
return "rowCount";
|
|
4197
4218
|
}
|
|
4198
4219
|
};
|
|
4199
|
-
const
|
|
4220
|
+
const getManyReturnType = (q) => {
|
|
4200
4221
|
const { select, returnType } = q.query;
|
|
4201
4222
|
if (select) {
|
|
4202
4223
|
return returnType === "one" || returnType === "oneOrThrow" ? "all" : returnType;
|
|
@@ -4204,18 +4225,18 @@ const getInsertManyReturnType = (q) => {
|
|
|
4204
4225
|
return "rowCount";
|
|
4205
4226
|
}
|
|
4206
4227
|
};
|
|
4207
|
-
const
|
|
4228
|
+
const handleOneData = (q, data, ctx) => {
|
|
4208
4229
|
const columns = [];
|
|
4209
4230
|
const columnsMap = {};
|
|
4210
4231
|
const defaults = q.query.defaults;
|
|
4211
4232
|
if (defaults) {
|
|
4212
4233
|
data = __spreadValues$4(__spreadValues$4({}, defaults), data);
|
|
4213
4234
|
}
|
|
4214
|
-
|
|
4235
|
+
processCreateItem(data, 0, ctx, columns, columnsMap);
|
|
4215
4236
|
const values = [columns.map((key) => data[key])];
|
|
4216
4237
|
return { columns, values };
|
|
4217
4238
|
};
|
|
4218
|
-
const
|
|
4239
|
+
const handleManyData = (q, data, ctx) => {
|
|
4219
4240
|
const columns = [];
|
|
4220
4241
|
const columnsMap = {};
|
|
4221
4242
|
const defaults = q.query.defaults;
|
|
@@ -4223,7 +4244,7 @@ const handleInsertManyData = (q, data, ctx) => {
|
|
|
4223
4244
|
data = data.map((item) => __spreadValues$4(__spreadValues$4({}, defaults), item));
|
|
4224
4245
|
}
|
|
4225
4246
|
data.forEach((item, i) => {
|
|
4226
|
-
|
|
4247
|
+
processCreateItem(item, i, ctx, columns, columnsMap);
|
|
4227
4248
|
});
|
|
4228
4249
|
const values = Array(data.length);
|
|
4229
4250
|
data.forEach((item, i) => {
|
|
@@ -4234,7 +4255,7 @@ const handleInsertManyData = (q, data, ctx) => {
|
|
|
4234
4255
|
const insert = (self, {
|
|
4235
4256
|
columns,
|
|
4236
4257
|
values
|
|
4237
|
-
}, returnType, ctx) => {
|
|
4258
|
+
}, returnType, ctx, fromQuery) => {
|
|
4238
4259
|
const q = self;
|
|
4239
4260
|
const returning = q.query.select;
|
|
4240
4261
|
delete q.query.and;
|
|
@@ -4242,6 +4263,7 @@ const insert = (self, {
|
|
|
4242
4263
|
q.query.type = "insert";
|
|
4243
4264
|
q.query.columns = columns;
|
|
4244
4265
|
q.query.values = values;
|
|
4266
|
+
q.query.fromQuery = fromQuery;
|
|
4245
4267
|
if (!ctx) {
|
|
4246
4268
|
q.query.returnType = returnType;
|
|
4247
4269
|
return q;
|
|
@@ -4317,67 +4339,72 @@ const insert = (self, {
|
|
|
4317
4339
|
q.query.returnType = appendRelationsKeys.length ? "all" : returnType;
|
|
4318
4340
|
return q;
|
|
4319
4341
|
};
|
|
4320
|
-
class
|
|
4321
|
-
|
|
4322
|
-
return this.clone().
|
|
4342
|
+
class Create {
|
|
4343
|
+
create(data) {
|
|
4344
|
+
return this.clone()._create(data);
|
|
4323
4345
|
}
|
|
4324
|
-
|
|
4325
|
-
|
|
4346
|
+
_create(data) {
|
|
4347
|
+
handleSelect(this);
|
|
4348
|
+
const ctx = createCtx(this);
|
|
4326
4349
|
return insert(
|
|
4327
4350
|
this,
|
|
4328
|
-
|
|
4329
|
-
|
|
4351
|
+
handleOneData(this, data, ctx),
|
|
4352
|
+
getSingleReturnType(this),
|
|
4330
4353
|
ctx
|
|
4331
4354
|
);
|
|
4332
4355
|
}
|
|
4333
|
-
|
|
4334
|
-
return this.clone().
|
|
4356
|
+
createMany(data) {
|
|
4357
|
+
return this.clone()._createMany(data);
|
|
4335
4358
|
}
|
|
4336
|
-
|
|
4337
|
-
|
|
4359
|
+
_createMany(data) {
|
|
4360
|
+
handleSelect(this);
|
|
4361
|
+
const ctx = createCtx(this);
|
|
4338
4362
|
return insert(
|
|
4339
4363
|
this,
|
|
4340
|
-
|
|
4341
|
-
|
|
4364
|
+
handleManyData(this, data, ctx),
|
|
4365
|
+
getManyReturnType(this),
|
|
4342
4366
|
ctx
|
|
4343
4367
|
);
|
|
4344
4368
|
}
|
|
4345
|
-
insertRaw(data) {
|
|
4346
|
-
return this.clone()._insertRaw(data);
|
|
4347
|
-
}
|
|
4348
|
-
_insertRaw(data) {
|
|
4349
|
-
return insert(
|
|
4350
|
-
this,
|
|
4351
|
-
data,
|
|
4352
|
-
getInsertManyReturnType(this)
|
|
4353
|
-
);
|
|
4354
|
-
}
|
|
4355
|
-
create(data) {
|
|
4356
|
-
return this.clone()._create(data);
|
|
4357
|
-
}
|
|
4358
|
-
_create(data) {
|
|
4359
|
-
if (!this.query.select) {
|
|
4360
|
-
this.query.select = ["*"];
|
|
4361
|
-
}
|
|
4362
|
-
return this.clone()._insert(data);
|
|
4363
|
-
}
|
|
4364
|
-
createMany(data) {
|
|
4365
|
-
return this.clone()._createMany(data);
|
|
4366
|
-
}
|
|
4367
|
-
_createMany(data) {
|
|
4368
|
-
if (!this.query.select) {
|
|
4369
|
-
this.query.select = ["*"];
|
|
4370
|
-
}
|
|
4371
|
-
return this.clone()._insertMany(data);
|
|
4372
|
-
}
|
|
4373
4369
|
createRaw(data) {
|
|
4374
4370
|
return this.clone()._createRaw(data);
|
|
4375
4371
|
}
|
|
4376
4372
|
_createRaw(data) {
|
|
4373
|
+
handleSelect(this);
|
|
4374
|
+
return insert(this, data, getManyReturnType(this));
|
|
4375
|
+
}
|
|
4376
|
+
createFrom(query, data) {
|
|
4377
|
+
return this.clone()._createFrom(query, data);
|
|
4378
|
+
}
|
|
4379
|
+
_createFrom(query, data) {
|
|
4380
|
+
var _a;
|
|
4381
|
+
if (!queryTypeWithLimitOne[query.query.returnType]) {
|
|
4382
|
+
throw new Error(
|
|
4383
|
+
"createFrom accepts only a query which returns one record"
|
|
4384
|
+
);
|
|
4385
|
+
}
|
|
4377
4386
|
if (!this.query.select) {
|
|
4378
4387
|
this.query.select = ["*"];
|
|
4379
4388
|
}
|
|
4380
|
-
|
|
4389
|
+
const ctx = createCtx(this);
|
|
4390
|
+
const queryColumns = [];
|
|
4391
|
+
(_a = query.query.select) == null ? void 0 : _a.forEach((item) => {
|
|
4392
|
+
if (typeof item === "string") {
|
|
4393
|
+
const index = item.indexOf(".");
|
|
4394
|
+
queryColumns.push(index === -1 ? item : item.slice(index + 1));
|
|
4395
|
+
} else if ("selectAs" in item) {
|
|
4396
|
+
queryColumns.push(...Object.keys(item.selectAs));
|
|
4397
|
+
}
|
|
4398
|
+
});
|
|
4399
|
+
const { columns, values } = handleOneData(this, data, ctx);
|
|
4400
|
+
queryColumns.push(...columns);
|
|
4401
|
+
return insert(
|
|
4402
|
+
this,
|
|
4403
|
+
{ columns: queryColumns, values },
|
|
4404
|
+
"one",
|
|
4405
|
+
ctx,
|
|
4406
|
+
query
|
|
4407
|
+
);
|
|
4381
4408
|
}
|
|
4382
4409
|
defaults(data) {
|
|
4383
4410
|
return this.clone()._defaults(data);
|
|
@@ -5320,7 +5347,7 @@ class QueryUpsert {
|
|
|
5320
5347
|
const { handleResult } = this.query;
|
|
5321
5348
|
this.query.handleResult = async (q, queryResult) => {
|
|
5322
5349
|
if (queryResult.rowCount === 0) {
|
|
5323
|
-
return q.
|
|
5350
|
+
return q.create(data.create);
|
|
5324
5351
|
} else if (queryResult.rowCount > 1) {
|
|
5325
5352
|
throw new MoreThanOneRowError(
|
|
5326
5353
|
`Only one row was expected to find for upsert, found ${queryResult.rowCount} rows.`
|
|
@@ -5506,7 +5533,7 @@ applyMixins(QueryMethods, [
|
|
|
5506
5533
|
With,
|
|
5507
5534
|
Union,
|
|
5508
5535
|
Json,
|
|
5509
|
-
|
|
5536
|
+
Create,
|
|
5510
5537
|
Update,
|
|
5511
5538
|
Delete,
|
|
5512
5539
|
Transaction,
|
|
@@ -5588,7 +5615,7 @@ class Db {
|
|
|
5588
5615
|
const defaultSelect = this.defaultSelectColumns.length === columns.length ? void 0 : this.defaultSelectColumns;
|
|
5589
5616
|
const columnsParsers = {};
|
|
5590
5617
|
let hasParsers = false;
|
|
5591
|
-
let modifyQuery;
|
|
5618
|
+
let modifyQuery = void 0;
|
|
5592
5619
|
for (const key in shape) {
|
|
5593
5620
|
const column = shape[key];
|
|
5594
5621
|
if (column.parseFn) {
|
|
@@ -5609,6 +5636,8 @@ class Db {
|
|
|
5609
5636
|
} : toSql;
|
|
5610
5637
|
this.relations = {};
|
|
5611
5638
|
modifyQuery == null ? void 0 : modifyQuery.forEach((cb) => cb(this));
|
|
5639
|
+
this.error = class extends QueryError {
|
|
5640
|
+
};
|
|
5612
5641
|
}
|
|
5613
5642
|
}
|
|
5614
5643
|
applyMixins(Db, [QueryMethods]);
|
|
@@ -5655,5 +5684,5 @@ const createDb = (_a) => {
|
|
|
5655
5684
|
const relationQueryKey = Symbol("relationQuery");
|
|
5656
5685
|
const isRequiredRelationKey = Symbol("isRequiredRelation");
|
|
5657
5686
|
|
|
5658
|
-
export { Adapter, Aggregate, ArrayColumn, ArrayOfColumnsObjects, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ColumnInfoMethods, ColumnType, ColumnsObject, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeWithTimeZoneBaseClass, Db, DecimalBaseColumn, DecimalColumn, Delete, DoublePrecisionColumn, EMPTY_OBJECT, EnumColumn, For, From, Having, InetColumn,
|
|
5687
|
+
export { Adapter, Aggregate, ArrayColumn, ArrayOfColumnsObjects, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ColumnInfoMethods, ColumnType, ColumnsObject, Create, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeWithTimeZoneBaseClass, Db, DecimalBaseColumn, DecimalColumn, Delete, DoublePrecisionColumn, EMPTY_OBJECT, EnumColumn, For, From, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, Json, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnQueryBuilder, Operators, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, QueryCallbacks, QueryError, QueryGet, QueryLog, QueryMethods, QueryUpsert, RealColumn, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, Transaction, TransactionAdapter, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, Update, VarCharColumn, Where, WhereQueryBuilder, With, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, applyMixins, array, arrayToEnum, checkIfASimpleQuery, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getRawSql, getTableData, getValidEnumValues, getValueKey, handleResult, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, makeRegexToFindInSql, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushOrNewArray, pushOrNewArrayToObject, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, raw, record, relationQueryKey, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, toSqlCacheKey, tuple, union };
|
|
5659
5688
|
//# sourceMappingURL=index.esm.js.map
|