orchid-orm 1.9.21 → 1.9.22
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.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -258,7 +258,8 @@ const nestedUpdate$3 = ({ query, primaryKey, foreignKey }) => {
|
|
|
258
258
|
if (id !== null) {
|
|
259
259
|
await query.findBy({ [primaryKey]: id })._update(upsert.update);
|
|
260
260
|
} else {
|
|
261
|
-
const
|
|
261
|
+
const data = typeof upsert.create === "function" ? upsert.create() : upsert.create;
|
|
262
|
+
const result = await query.select(primaryKey)._create(data);
|
|
262
263
|
((_a2 = state.updateData) != null ? _a2 : state.updateData = {})[foreignKey] = result[primaryKey];
|
|
263
264
|
}
|
|
264
265
|
});
|
|
@@ -523,8 +524,9 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
523
524
|
const { update, create } = params.upsert;
|
|
524
525
|
const updatedIds = await currentRelationsQuery._pluck(foreignKey)._update(update);
|
|
525
526
|
if (updatedIds.length < ids.length) {
|
|
527
|
+
const data2 = typeof create === "function" ? create() : create;
|
|
526
528
|
await t.createMany(
|
|
527
|
-
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$7({},
|
|
529
|
+
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$7({}, data2), {
|
|
528
530
|
[foreignKey]: id
|
|
529
531
|
}))
|
|
530
532
|
);
|
|
@@ -1245,6 +1247,16 @@ const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, de
|
|
|
1245
1247
|
}
|
|
1246
1248
|
makeRelationQuery(dbTable, relationName, data, query);
|
|
1247
1249
|
baseQuery.joinQuery = data.joinQuery;
|
|
1250
|
+
const { join: originalJoin } = baseQuery;
|
|
1251
|
+
baseQuery.join = function(...args) {
|
|
1252
|
+
if (args.length) {
|
|
1253
|
+
return originalJoin.apply(this, args);
|
|
1254
|
+
} else {
|
|
1255
|
+
const q = this.clone();
|
|
1256
|
+
q.query.innerJoinLateral = true;
|
|
1257
|
+
return q;
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1248
1260
|
dbTable.relations[relationName] = {
|
|
1249
1261
|
type,
|
|
1250
1262
|
key: relationName,
|