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 CHANGED
@@ -277,7 +277,8 @@ const nestedUpdate$3 = ({ query, primaryKey, foreignKey }) => {
277
277
  if (id !== null) {
278
278
  await query.findBy({ [primaryKey]: id })._update(upsert.update);
279
279
  } else {
280
- const result = await query.select(primaryKey)._create(upsert.create);
280
+ const data = typeof upsert.create === "function" ? upsert.create() : upsert.create;
281
+ const result = await query.select(primaryKey)._create(data);
281
282
  ((_a2 = state.updateData) != null ? _a2 : state.updateData = {})[foreignKey] = result[primaryKey];
282
283
  }
283
284
  });
@@ -542,8 +543,9 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
542
543
  const { update, create } = params.upsert;
543
544
  const updatedIds = await currentRelationsQuery._pluck(foreignKey)._update(update);
544
545
  if (updatedIds.length < ids.length) {
546
+ const data2 = typeof create === "function" ? create() : create;
545
547
  await t.createMany(
546
- ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$7({}, create), {
548
+ ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$7({}, data2), {
547
549
  [foreignKey]: id
548
550
  }))
549
551
  );
@@ -1264,6 +1266,16 @@ const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, de
1264
1266
  }
1265
1267
  makeRelationQuery(dbTable, relationName, data, query);
1266
1268
  baseQuery.joinQuery = data.joinQuery;
1269
+ const { join: originalJoin } = baseQuery;
1270
+ baseQuery.join = function(...args) {
1271
+ if (args.length) {
1272
+ return originalJoin.apply(this, args);
1273
+ } else {
1274
+ const q = this.clone();
1275
+ q.query.innerJoinLateral = true;
1276
+ return q;
1277
+ }
1278
+ };
1267
1279
  dbTable.relations[relationName] = {
1268
1280
  type,
1269
1281
  key: relationName,