pqb 0.7.4 → 0.7.6
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +79 -79
- package/dist/index.esm.js +44 -53
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +44 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/columnsOperators.test.ts +30 -30
- package/src/columnsOperators.ts +13 -13
- package/src/queryMethods/delete.test.ts +4 -4
- package/src/queryMethods/delete.ts +16 -24
- package/src/queryMethods/update.test.ts +4 -6
- package/src/queryMethods/update.ts +26 -57
package/dist/index.esm.js
CHANGED
|
@@ -259,23 +259,23 @@ const all = {
|
|
|
259
259
|
(key, value, values) => `${key} >= ${quoteValue(value, values)}`
|
|
260
260
|
),
|
|
261
261
|
contains: () => createOperator(
|
|
262
|
-
(key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`
|
|
263
|
-
),
|
|
264
|
-
containsInsensitive: () => createOperator(
|
|
265
262
|
(key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)} || '%'`
|
|
266
263
|
),
|
|
267
|
-
|
|
268
|
-
(key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
|
|
264
|
+
containsSensitive: () => createOperator(
|
|
265
|
+
(key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`
|
|
269
266
|
),
|
|
270
|
-
|
|
267
|
+
startsWith: () => createOperator(
|
|
271
268
|
(key, value, values) => `${key} ILIKE ${quoteValue(value, values)} || '%'`
|
|
272
269
|
),
|
|
273
|
-
|
|
274
|
-
(key, value, values) => `${key} LIKE
|
|
270
|
+
startsWithSensitive: () => createOperator(
|
|
271
|
+
(key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
|
|
275
272
|
),
|
|
276
|
-
|
|
273
|
+
endsWith: () => createOperator(
|
|
277
274
|
(key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)}`
|
|
278
275
|
),
|
|
276
|
+
endsWithSensitive: () => createOperator(
|
|
277
|
+
(key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)}`
|
|
278
|
+
),
|
|
279
279
|
between: () => createOperator(
|
|
280
280
|
(key, [from, to], values) => `${key} BETWEEN ${quoteValue(from, values)} AND ${quoteValue(
|
|
281
281
|
to,
|
|
@@ -309,11 +309,11 @@ const numeric = () => __spreadProps$j(__spreadValues$p({}, base()), {
|
|
|
309
309
|
});
|
|
310
310
|
const text$1 = () => __spreadProps$j(__spreadValues$p({}, base()), {
|
|
311
311
|
contains: all.contains(),
|
|
312
|
-
|
|
312
|
+
containsSensitive: all.containsSensitive(),
|
|
313
313
|
startsWith: all.startsWith(),
|
|
314
|
-
|
|
314
|
+
startsWithSensitive: all.startsWithSensitive(),
|
|
315
315
|
endsWith: all.endsWith(),
|
|
316
|
-
|
|
316
|
+
endsWithSensitive: all.endsWithSensitive()
|
|
317
317
|
});
|
|
318
318
|
const json = () => __spreadProps$j(__spreadValues$p({}, base()), {
|
|
319
319
|
jsonPath: all.jsonPath(),
|
|
@@ -4076,14 +4076,10 @@ class ColumnInfoMethods {
|
|
|
4076
4076
|
}
|
|
4077
4077
|
}
|
|
4078
4078
|
|
|
4079
|
-
const del = (self
|
|
4080
|
-
return self.clone()
|
|
4079
|
+
const del = (self) => {
|
|
4080
|
+
return _del(self.clone());
|
|
4081
4081
|
};
|
|
4082
|
-
const _del = (q
|
|
4083
|
-
var _a, _b;
|
|
4084
|
-
if (!((_a = q.query.and) == null ? void 0 : _a.length) && !((_b = q.query.or) == null ? void 0 : _b.length) && !args[0]) {
|
|
4085
|
-
throw new Error("No where conditions or forceAll flag provided to delete");
|
|
4086
|
-
}
|
|
4082
|
+
const _del = (q) => {
|
|
4087
4083
|
if (!q.query.select) {
|
|
4088
4084
|
q.query.returnType = "rowCount";
|
|
4089
4085
|
}
|
|
@@ -4091,17 +4087,17 @@ const _del = (q, ...args) => {
|
|
|
4091
4087
|
return q;
|
|
4092
4088
|
};
|
|
4093
4089
|
class Delete {
|
|
4094
|
-
del(...
|
|
4095
|
-
return del(this
|
|
4090
|
+
del(..._args) {
|
|
4091
|
+
return del(this);
|
|
4096
4092
|
}
|
|
4097
|
-
_del(...
|
|
4098
|
-
return _del(this
|
|
4093
|
+
_del(..._args) {
|
|
4094
|
+
return _del(this);
|
|
4099
4095
|
}
|
|
4100
|
-
delete(...
|
|
4101
|
-
return del(this
|
|
4096
|
+
delete(..._args) {
|
|
4097
|
+
return del(this);
|
|
4102
4098
|
}
|
|
4103
|
-
_delete(...
|
|
4104
|
-
return _del(this
|
|
4099
|
+
_delete(..._args) {
|
|
4100
|
+
return _del(this);
|
|
4105
4101
|
}
|
|
4106
4102
|
}
|
|
4107
4103
|
|
|
@@ -5213,40 +5209,35 @@ const checkIfUpdateIsEmpty = (q) => {
|
|
|
5213
5209
|
var _a;
|
|
5214
5210
|
return !((_a = q.updateData) == null ? void 0 : _a.some((item) => isRaw(item) || Object.keys(item).length));
|
|
5215
5211
|
};
|
|
5216
|
-
const update = (q
|
|
5217
|
-
var _a, _b;
|
|
5212
|
+
const update = (q) => {
|
|
5218
5213
|
const { query } = q;
|
|
5219
5214
|
query.type = "update";
|
|
5220
|
-
if (!((_a = query.and) == null ? void 0 : _a.length) && !((_b = query.or) == null ? void 0 : _b.length) && !forceAll) {
|
|
5221
|
-
throw new Error("No where conditions or forceAll flag provided to update");
|
|
5222
|
-
}
|
|
5223
5215
|
if (!query.select) {
|
|
5224
5216
|
query.returnType = "rowCount";
|
|
5225
5217
|
}
|
|
5226
5218
|
return q;
|
|
5227
5219
|
};
|
|
5228
5220
|
class Update {
|
|
5229
|
-
update(
|
|
5221
|
+
update(arg) {
|
|
5230
5222
|
const q = this.clone();
|
|
5231
|
-
return q._update(
|
|
5223
|
+
return q._update(arg);
|
|
5232
5224
|
}
|
|
5233
|
-
_update(
|
|
5225
|
+
_update(arg) {
|
|
5234
5226
|
var _a, _b, _c;
|
|
5235
5227
|
const { query } = this;
|
|
5236
|
-
const
|
|
5237
|
-
const set = __spreadValues$1({}, data);
|
|
5228
|
+
const set = __spreadValues$1({}, arg);
|
|
5238
5229
|
pushQueryValue(this, "updateData", set);
|
|
5239
5230
|
const { relations, shape } = this;
|
|
5240
5231
|
const prependRelations = {};
|
|
5241
5232
|
const appendRelations = {};
|
|
5242
5233
|
const originalReturnType = query.returnType || "all";
|
|
5243
|
-
for (const key in
|
|
5234
|
+
for (const key in arg) {
|
|
5244
5235
|
if (relations[key]) {
|
|
5245
5236
|
delete set[key];
|
|
5246
5237
|
if (relations[key].type === "belongsTo") {
|
|
5247
|
-
prependRelations[key] =
|
|
5238
|
+
prependRelations[key] = arg[key];
|
|
5248
5239
|
} else {
|
|
5249
|
-
const value =
|
|
5240
|
+
const value = arg[key];
|
|
5250
5241
|
if (!value.set && !("upsert" in value) && (!value.disconnect || Array.isArray(value.disconnect) && value.disconnect.length === 0) && (!value.delete || Array.isArray(value.delete) && value.delete.length === 0) && (!value.update || Array.isArray(value.update.where) && value.update.where.length === 0) && (!value.create || Array.isArray(value.create) && value.create.length === 0))
|
|
5251
5242
|
continue;
|
|
5252
5243
|
if (!((_a = query.select) == null ? void 0 : _a.includes("*"))) {
|
|
@@ -5255,7 +5246,7 @@ class Update {
|
|
|
5255
5246
|
this._select(primaryKey);
|
|
5256
5247
|
}
|
|
5257
5248
|
}
|
|
5258
|
-
appendRelations[key] =
|
|
5249
|
+
appendRelations[key] = arg[key];
|
|
5259
5250
|
}
|
|
5260
5251
|
} else if (!shape[key] && shape !== anyShape) {
|
|
5261
5252
|
delete set[key];
|
|
@@ -5270,8 +5261,8 @@ class Update {
|
|
|
5270
5261
|
let willSetKeys = false;
|
|
5271
5262
|
if (prependRelationKeys.length) {
|
|
5272
5263
|
willSetKeys = prependRelationKeys.some((relationName) => {
|
|
5273
|
-
const
|
|
5274
|
-
return relations[relationName].nestedUpdate(this, set,
|
|
5264
|
+
const data = prependRelations[relationName];
|
|
5265
|
+
return relations[relationName].nestedUpdate(this, set, data, state);
|
|
5275
5266
|
});
|
|
5276
5267
|
}
|
|
5277
5268
|
if (!willSetKeys && checkIfUpdateIsEmpty(query)) {
|
|
@@ -5334,23 +5325,23 @@ class Update {
|
|
|
5334
5325
|
if (prependRelationKeys.length || appendRelationKeys.length) {
|
|
5335
5326
|
query.wrapInTransaction = true;
|
|
5336
5327
|
}
|
|
5337
|
-
return update(this
|
|
5328
|
+
return update(this);
|
|
5338
5329
|
}
|
|
5339
|
-
updateRaw(
|
|
5330
|
+
updateRaw(arg) {
|
|
5340
5331
|
const q = this.clone();
|
|
5341
|
-
return q._updateRaw(
|
|
5332
|
+
return q._updateRaw(arg);
|
|
5342
5333
|
}
|
|
5343
|
-
_updateRaw(
|
|
5344
|
-
pushQueryValue(this, "updateData",
|
|
5345
|
-
return update(this
|
|
5334
|
+
_updateRaw(arg) {
|
|
5335
|
+
pushQueryValue(this, "updateData", arg);
|
|
5336
|
+
return update(this);
|
|
5346
5337
|
}
|
|
5347
|
-
updateOrThrow(
|
|
5338
|
+
updateOrThrow(arg) {
|
|
5348
5339
|
const q = this.clone();
|
|
5349
|
-
return q._updateOrThrow(
|
|
5340
|
+
return q._updateOrThrow(arg);
|
|
5350
5341
|
}
|
|
5351
|
-
_updateOrThrow(
|
|
5342
|
+
_updateOrThrow(arg) {
|
|
5352
5343
|
this.query.throwOnNotFound = true;
|
|
5353
|
-
return this._update(
|
|
5344
|
+
return this._update(arg);
|
|
5354
5345
|
}
|
|
5355
5346
|
increment(data) {
|
|
5356
5347
|
return this.clone()._increment(data);
|