pqb 0.2.7 → 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.d.ts +6 -6
- package/dist/index.esm.js +12 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/queryMethods/then.ts +2 -2
- package/src/queryMethods/update.ts +24 -20
package/dist/index.js
CHANGED
|
@@ -3252,10 +3252,10 @@ class QueryGet {
|
|
|
3252
3252
|
|
|
3253
3253
|
const queryMethodByReturnType = {
|
|
3254
3254
|
all: "query",
|
|
3255
|
-
one: "query",
|
|
3256
|
-
oneOrThrow: "query",
|
|
3257
3255
|
rows: "arrays",
|
|
3258
3256
|
pluck: "arrays",
|
|
3257
|
+
one: "query",
|
|
3258
|
+
oneOrThrow: "query",
|
|
3259
3259
|
value: "arrays",
|
|
3260
3260
|
valueOrThrow: "arrays",
|
|
3261
3261
|
rowCount: "arrays",
|
|
@@ -4557,6 +4557,10 @@ const applyCountChange = (self, op, data) => {
|
|
|
4557
4557
|
pushQueryValue(self, "data", map);
|
|
4558
4558
|
return self;
|
|
4559
4559
|
};
|
|
4560
|
+
const checkIfUpdateIsEmpty = (q) => {
|
|
4561
|
+
var _a;
|
|
4562
|
+
return !((_a = q.data) == null ? void 0 : _a.some((item) => isRaw(item) || Object.keys(item).length));
|
|
4563
|
+
};
|
|
4560
4564
|
class Update {
|
|
4561
4565
|
update(...args) {
|
|
4562
4566
|
const q = this.clone();
|
|
@@ -4575,11 +4579,12 @@ class Update {
|
|
|
4575
4579
|
if (isRaw(data)) {
|
|
4576
4580
|
pushQueryValue(this, "data", data);
|
|
4577
4581
|
} else {
|
|
4582
|
+
const update = __spreadValues$2({}, data);
|
|
4583
|
+
pushQueryValue(this, "data", update);
|
|
4578
4584
|
const relations = this.relations;
|
|
4579
4585
|
const prependRelations = {};
|
|
4580
4586
|
const appendRelations = {};
|
|
4581
4587
|
const originalReturnType = this.query.returnType;
|
|
4582
|
-
const update = __spreadValues$2({}, data);
|
|
4583
4588
|
for (const key in data) {
|
|
4584
4589
|
if (relations[key]) {
|
|
4585
4590
|
delete update[key];
|
|
@@ -4598,15 +4603,14 @@ class Update {
|
|
|
4598
4603
|
}
|
|
4599
4604
|
const state = {};
|
|
4600
4605
|
const prependRelationKeys = Object.keys(prependRelations);
|
|
4606
|
+
let willSetKeys = false;
|
|
4601
4607
|
if (prependRelationKeys.length) {
|
|
4602
|
-
|
|
4608
|
+
willSetKeys = prependRelationKeys.some((relationName) => {
|
|
4603
4609
|
const data2 = prependRelations[relationName];
|
|
4604
4610
|
return relations[relationName].nestedUpdate(this, update, data2, state);
|
|
4605
4611
|
});
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
}
|
|
4609
|
-
} else if (!Object.keys(update).length) {
|
|
4612
|
+
}
|
|
4613
|
+
if (!willSetKeys && checkIfUpdateIsEmpty(this.query)) {
|
|
4610
4614
|
delete this.query.type;
|
|
4611
4615
|
}
|
|
4612
4616
|
const appendRelationKeys = Object.keys(appendRelations);
|
|
@@ -4661,7 +4665,6 @@ class Update {
|
|
|
4661
4665
|
if (prependRelationKeys.length || appendRelationKeys.length) {
|
|
4662
4666
|
query.wrapInTransaction = true;
|
|
4663
4667
|
}
|
|
4664
|
-
pushQueryValue(this, "data", update);
|
|
4665
4668
|
}
|
|
4666
4669
|
if (!query.select) {
|
|
4667
4670
|
this.query.returnType = "rowCount";
|