pqb 0.2.8 → 0.2.9

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
@@ -4553,6 +4553,10 @@ const applyCountChange = (self, op, data) => {
4553
4553
  pushQueryValue(self, "data", map);
4554
4554
  return self;
4555
4555
  };
4556
+ const checkIfUpdateIsEmpty = (q) => {
4557
+ var _a;
4558
+ return !((_a = q.data) == null ? void 0 : _a.some((item) => isRaw(item) || Object.keys(item).length));
4559
+ };
4556
4560
  class Update {
4557
4561
  update(...args) {
4558
4562
  const q = this.clone();
@@ -4571,11 +4575,12 @@ class Update {
4571
4575
  if (isRaw(data)) {
4572
4576
  pushQueryValue(this, "data", data);
4573
4577
  } else {
4578
+ const update = __spreadValues$2({}, data);
4579
+ pushQueryValue(this, "data", update);
4574
4580
  const relations = this.relations;
4575
4581
  const prependRelations = {};
4576
4582
  const appendRelations = {};
4577
4583
  const originalReturnType = this.query.returnType;
4578
- const update = __spreadValues$2({}, data);
4579
4584
  for (const key in data) {
4580
4585
  if (relations[key]) {
4581
4586
  delete update[key];
@@ -4594,15 +4599,14 @@ class Update {
4594
4599
  }
4595
4600
  const state = {};
4596
4601
  const prependRelationKeys = Object.keys(prependRelations);
4602
+ let willSetKeys = false;
4597
4603
  if (prependRelationKeys.length) {
4598
- const willSetKeys = prependRelationKeys.some((relationName) => {
4604
+ willSetKeys = prependRelationKeys.some((relationName) => {
4599
4605
  const data2 = prependRelations[relationName];
4600
4606
  return relations[relationName].nestedUpdate(this, update, data2, state);
4601
4607
  });
4602
- if (!willSetKeys && !Object.keys(update).length) {
4603
- delete this.query.type;
4604
- }
4605
- } else if (!Object.keys(update).length) {
4608
+ }
4609
+ if (!willSetKeys && checkIfUpdateIsEmpty(this.query)) {
4606
4610
  delete this.query.type;
4607
4611
  }
4608
4612
  const appendRelationKeys = Object.keys(appendRelations);
@@ -4657,7 +4661,6 @@ class Update {
4657
4661
  if (prependRelationKeys.length || appendRelationKeys.length) {
4658
4662
  query.wrapInTransaction = true;
4659
4663
  }
4660
- pushQueryValue(this, "data", update);
4661
4664
  }
4662
4665
  if (!query.select) {
4663
4666
  this.query.returnType = "rowCount";