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/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
- startsWith: () => createOperator(
268
- (key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
264
+ containsSensitive: () => createOperator(
265
+ (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`
269
266
  ),
270
- startsWithInsensitive: () => createOperator(
267
+ startsWith: () => createOperator(
271
268
  (key, value, values) => `${key} ILIKE ${quoteValue(value, values)} || '%'`
272
269
  ),
273
- endsWith: () => createOperator(
274
- (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)}`
270
+ startsWithSensitive: () => createOperator(
271
+ (key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
275
272
  ),
276
- endsWithInsensitive: () => createOperator(
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
- containsInsensitive: all.containsInsensitive(),
312
+ containsSensitive: all.containsSensitive(),
313
313
  startsWith: all.startsWith(),
314
- startsWithInsensitive: all.startsWithInsensitive(),
314
+ startsWithSensitive: all.startsWithSensitive(),
315
315
  endsWith: all.endsWith(),
316
- endsWithInsensitive: all.endsWithInsensitive()
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, ...args) => {
4080
- return self.clone()._del(...args);
4079
+ const del = (self) => {
4080
+ return _del(self.clone());
4081
4081
  };
4082
- const _del = (q, ...args) => {
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(...args) {
4095
- return del(this, ...args);
4090
+ del(..._args) {
4091
+ return del(this);
4096
4092
  }
4097
- _del(...args) {
4098
- return _del(this, ...args);
4093
+ _del(..._args) {
4094
+ return _del(this);
4099
4095
  }
4100
- delete(...args) {
4101
- return del(this, ...args);
4096
+ delete(..._args) {
4097
+ return del(this);
4102
4098
  }
4103
- _delete(...args) {
4104
- return _del(this, ...args);
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, forceAll) => {
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(...args) {
5221
+ update(arg) {
5230
5222
  const q = this.clone();
5231
- return q._update(...args);
5223
+ return q._update(arg);
5232
5224
  }
5233
- _update(...args) {
5225
+ _update(arg) {
5234
5226
  var _a, _b, _c;
5235
5227
  const { query } = this;
5236
- const data = args[0];
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 data) {
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] = data[key];
5238
+ prependRelations[key] = arg[key];
5248
5239
  } else {
5249
- const value = data[key];
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] = data[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 data2 = prependRelations[relationName];
5274
- return relations[relationName].nestedUpdate(this, set, data2, state);
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, args[1]);
5328
+ return update(this);
5338
5329
  }
5339
- updateRaw(...args) {
5330
+ updateRaw(arg) {
5340
5331
  const q = this.clone();
5341
- return q._updateRaw(...args);
5332
+ return q._updateRaw(arg);
5342
5333
  }
5343
- _updateRaw(...args) {
5344
- pushQueryValue(this, "updateData", args[0]);
5345
- return update(this, args[1]);
5334
+ _updateRaw(arg) {
5335
+ pushQueryValue(this, "updateData", arg);
5336
+ return update(this);
5346
5337
  }
5347
- updateOrThrow(...args) {
5338
+ updateOrThrow(arg) {
5348
5339
  const q = this.clone();
5349
- return q._updateOrThrow(...args);
5340
+ return q._updateOrThrow(arg);
5350
5341
  }
5351
- _updateOrThrow(...args) {
5342
+ _updateOrThrow(arg) {
5352
5343
  this.query.throwOnNotFound = true;
5353
- return this._update(...args);
5344
+ return this._update(arg);
5354
5345
  }
5355
5346
  increment(data) {
5356
5347
  return this.clone()._increment(data);