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.js
CHANGED
|
@@ -263,23 +263,23 @@ const all = {
|
|
|
263
263
|
(key, value, values) => `${key} >= ${quoteValue(value, values)}`
|
|
264
264
|
),
|
|
265
265
|
contains: () => createOperator(
|
|
266
|
-
(key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`
|
|
267
|
-
),
|
|
268
|
-
containsInsensitive: () => createOperator(
|
|
269
266
|
(key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)} || '%'`
|
|
270
267
|
),
|
|
271
|
-
|
|
272
|
-
(key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
|
|
268
|
+
containsSensitive: () => createOperator(
|
|
269
|
+
(key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`
|
|
273
270
|
),
|
|
274
|
-
|
|
271
|
+
startsWith: () => createOperator(
|
|
275
272
|
(key, value, values) => `${key} ILIKE ${quoteValue(value, values)} || '%'`
|
|
276
273
|
),
|
|
277
|
-
|
|
278
|
-
(key, value, values) => `${key} LIKE
|
|
274
|
+
startsWithSensitive: () => createOperator(
|
|
275
|
+
(key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
|
|
279
276
|
),
|
|
280
|
-
|
|
277
|
+
endsWith: () => createOperator(
|
|
281
278
|
(key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)}`
|
|
282
279
|
),
|
|
280
|
+
endsWithSensitive: () => createOperator(
|
|
281
|
+
(key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)}`
|
|
282
|
+
),
|
|
283
283
|
between: () => createOperator(
|
|
284
284
|
(key, [from, to], values) => `${key} BETWEEN ${quoteValue(from, values)} AND ${quoteValue(
|
|
285
285
|
to,
|
|
@@ -313,11 +313,11 @@ const numeric = () => __spreadProps$j(__spreadValues$p({}, base()), {
|
|
|
313
313
|
});
|
|
314
314
|
const text$1 = () => __spreadProps$j(__spreadValues$p({}, base()), {
|
|
315
315
|
contains: all.contains(),
|
|
316
|
-
|
|
316
|
+
containsSensitive: all.containsSensitive(),
|
|
317
317
|
startsWith: all.startsWith(),
|
|
318
|
-
|
|
318
|
+
startsWithSensitive: all.startsWithSensitive(),
|
|
319
319
|
endsWith: all.endsWith(),
|
|
320
|
-
|
|
320
|
+
endsWithSensitive: all.endsWithSensitive()
|
|
321
321
|
});
|
|
322
322
|
const json = () => __spreadProps$j(__spreadValues$p({}, base()), {
|
|
323
323
|
jsonPath: all.jsonPath(),
|
|
@@ -4080,14 +4080,10 @@ class ColumnInfoMethods {
|
|
|
4080
4080
|
}
|
|
4081
4081
|
}
|
|
4082
4082
|
|
|
4083
|
-
const del = (self
|
|
4084
|
-
return self.clone()
|
|
4083
|
+
const del = (self) => {
|
|
4084
|
+
return _del(self.clone());
|
|
4085
4085
|
};
|
|
4086
|
-
const _del = (q
|
|
4087
|
-
var _a, _b;
|
|
4088
|
-
if (!((_a = q.query.and) == null ? void 0 : _a.length) && !((_b = q.query.or) == null ? void 0 : _b.length) && !args[0]) {
|
|
4089
|
-
throw new Error("No where conditions or forceAll flag provided to delete");
|
|
4090
|
-
}
|
|
4086
|
+
const _del = (q) => {
|
|
4091
4087
|
if (!q.query.select) {
|
|
4092
4088
|
q.query.returnType = "rowCount";
|
|
4093
4089
|
}
|
|
@@ -4095,17 +4091,17 @@ const _del = (q, ...args) => {
|
|
|
4095
4091
|
return q;
|
|
4096
4092
|
};
|
|
4097
4093
|
class Delete {
|
|
4098
|
-
del(...
|
|
4099
|
-
return del(this
|
|
4094
|
+
del(..._args) {
|
|
4095
|
+
return del(this);
|
|
4100
4096
|
}
|
|
4101
|
-
_del(...
|
|
4102
|
-
return _del(this
|
|
4097
|
+
_del(..._args) {
|
|
4098
|
+
return _del(this);
|
|
4103
4099
|
}
|
|
4104
|
-
delete(...
|
|
4105
|
-
return del(this
|
|
4100
|
+
delete(..._args) {
|
|
4101
|
+
return del(this);
|
|
4106
4102
|
}
|
|
4107
|
-
_delete(...
|
|
4108
|
-
return _del(this
|
|
4103
|
+
_delete(..._args) {
|
|
4104
|
+
return _del(this);
|
|
4109
4105
|
}
|
|
4110
4106
|
}
|
|
4111
4107
|
|
|
@@ -5217,40 +5213,35 @@ const checkIfUpdateIsEmpty = (q) => {
|
|
|
5217
5213
|
var _a;
|
|
5218
5214
|
return !((_a = q.updateData) == null ? void 0 : _a.some((item) => isRaw(item) || Object.keys(item).length));
|
|
5219
5215
|
};
|
|
5220
|
-
const update = (q
|
|
5221
|
-
var _a, _b;
|
|
5216
|
+
const update = (q) => {
|
|
5222
5217
|
const { query } = q;
|
|
5223
5218
|
query.type = "update";
|
|
5224
|
-
if (!((_a = query.and) == null ? void 0 : _a.length) && !((_b = query.or) == null ? void 0 : _b.length) && !forceAll) {
|
|
5225
|
-
throw new Error("No where conditions or forceAll flag provided to update");
|
|
5226
|
-
}
|
|
5227
5219
|
if (!query.select) {
|
|
5228
5220
|
query.returnType = "rowCount";
|
|
5229
5221
|
}
|
|
5230
5222
|
return q;
|
|
5231
5223
|
};
|
|
5232
5224
|
class Update {
|
|
5233
|
-
update(
|
|
5225
|
+
update(arg) {
|
|
5234
5226
|
const q = this.clone();
|
|
5235
|
-
return q._update(
|
|
5227
|
+
return q._update(arg);
|
|
5236
5228
|
}
|
|
5237
|
-
_update(
|
|
5229
|
+
_update(arg) {
|
|
5238
5230
|
var _a, _b, _c;
|
|
5239
5231
|
const { query } = this;
|
|
5240
|
-
const
|
|
5241
|
-
const set = __spreadValues$1({}, data);
|
|
5232
|
+
const set = __spreadValues$1({}, arg);
|
|
5242
5233
|
pushQueryValue(this, "updateData", set);
|
|
5243
5234
|
const { relations, shape } = this;
|
|
5244
5235
|
const prependRelations = {};
|
|
5245
5236
|
const appendRelations = {};
|
|
5246
5237
|
const originalReturnType = query.returnType || "all";
|
|
5247
|
-
for (const key in
|
|
5238
|
+
for (const key in arg) {
|
|
5248
5239
|
if (relations[key]) {
|
|
5249
5240
|
delete set[key];
|
|
5250
5241
|
if (relations[key].type === "belongsTo") {
|
|
5251
|
-
prependRelations[key] =
|
|
5242
|
+
prependRelations[key] = arg[key];
|
|
5252
5243
|
} else {
|
|
5253
|
-
const value =
|
|
5244
|
+
const value = arg[key];
|
|
5254
5245
|
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))
|
|
5255
5246
|
continue;
|
|
5256
5247
|
if (!((_a = query.select) == null ? void 0 : _a.includes("*"))) {
|
|
@@ -5259,7 +5250,7 @@ class Update {
|
|
|
5259
5250
|
this._select(primaryKey);
|
|
5260
5251
|
}
|
|
5261
5252
|
}
|
|
5262
|
-
appendRelations[key] =
|
|
5253
|
+
appendRelations[key] = arg[key];
|
|
5263
5254
|
}
|
|
5264
5255
|
} else if (!shape[key] && shape !== anyShape) {
|
|
5265
5256
|
delete set[key];
|
|
@@ -5274,8 +5265,8 @@ class Update {
|
|
|
5274
5265
|
let willSetKeys = false;
|
|
5275
5266
|
if (prependRelationKeys.length) {
|
|
5276
5267
|
willSetKeys = prependRelationKeys.some((relationName) => {
|
|
5277
|
-
const
|
|
5278
|
-
return relations[relationName].nestedUpdate(this, set,
|
|
5268
|
+
const data = prependRelations[relationName];
|
|
5269
|
+
return relations[relationName].nestedUpdate(this, set, data, state);
|
|
5279
5270
|
});
|
|
5280
5271
|
}
|
|
5281
5272
|
if (!willSetKeys && checkIfUpdateIsEmpty(query)) {
|
|
@@ -5338,23 +5329,23 @@ class Update {
|
|
|
5338
5329
|
if (prependRelationKeys.length || appendRelationKeys.length) {
|
|
5339
5330
|
query.wrapInTransaction = true;
|
|
5340
5331
|
}
|
|
5341
|
-
return update(this
|
|
5332
|
+
return update(this);
|
|
5342
5333
|
}
|
|
5343
|
-
updateRaw(
|
|
5334
|
+
updateRaw(arg) {
|
|
5344
5335
|
const q = this.clone();
|
|
5345
|
-
return q._updateRaw(
|
|
5336
|
+
return q._updateRaw(arg);
|
|
5346
5337
|
}
|
|
5347
|
-
_updateRaw(
|
|
5348
|
-
pushQueryValue(this, "updateData",
|
|
5349
|
-
return update(this
|
|
5338
|
+
_updateRaw(arg) {
|
|
5339
|
+
pushQueryValue(this, "updateData", arg);
|
|
5340
|
+
return update(this);
|
|
5350
5341
|
}
|
|
5351
|
-
updateOrThrow(
|
|
5342
|
+
updateOrThrow(arg) {
|
|
5352
5343
|
const q = this.clone();
|
|
5353
|
-
return q._updateOrThrow(
|
|
5344
|
+
return q._updateOrThrow(arg);
|
|
5354
5345
|
}
|
|
5355
|
-
_updateOrThrow(
|
|
5346
|
+
_updateOrThrow(arg) {
|
|
5356
5347
|
this.query.throwOnNotFound = true;
|
|
5357
|
-
return this._update(
|
|
5348
|
+
return this._update(arg);
|
|
5358
5349
|
}
|
|
5359
5350
|
increment(data) {
|
|
5360
5351
|
return this.clone()._increment(data);
|