orchid-orm 1.35.19 → 1.35.20

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
@@ -1111,8 +1111,8 @@ const nestedUpdate$1 = ({ query, primaryKeys, foreignKeys }) => {
1111
1111
  };
1112
1112
 
1113
1113
  var __defProp$3 = Object.defineProperty;
1114
- var __defProps$1 = Object.defineProperties;
1115
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1114
+ var __defProps$2 = Object.defineProperties;
1115
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1116
1116
  var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1117
1117
  var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1118
1118
  var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
@@ -1128,7 +1128,7 @@ var __spreadValues$3 = (a, b) => {
1128
1128
  }
1129
1129
  return a;
1130
1130
  };
1131
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1131
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1132
1132
  class HasAndBelongsToManyVirtualColumn extends pqb.VirtualColumn {
1133
1133
  constructor(joinTable, schema, key, state) {
1134
1134
  super(schema);
@@ -1163,7 +1163,7 @@ const removeColumnName = (column) => {
1163
1163
  if (!column.data.name)
1164
1164
  return column;
1165
1165
  const cloned = Object.create(column);
1166
- cloned.data = __spreadProps$1(__spreadValues$3({}, column.data), { name: void 0 });
1166
+ cloned.data = __spreadProps$2(__spreadValues$3({}, column.data), { name: void 0 });
1167
1167
  return cloned;
1168
1168
  };
1169
1169
  const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query) => {
@@ -1205,7 +1205,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
1205
1205
  );
1206
1206
  }
1207
1207
  baseQuery.shape = shape;
1208
- baseQuery.q = __spreadProps$1(__spreadValues$3({}, baseQuery.q), {
1208
+ baseQuery.q = __spreadProps$2(__spreadValues$3({}, baseQuery.q), {
1209
1209
  shape: baseQuery.shape
1210
1210
  });
1211
1211
  const subQuery = Object.create(baseQuery);
@@ -1245,7 +1245,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
1245
1245
  const selectPrimaryKeysAsForeignKeys = [{ selectAs: obj }];
1246
1246
  const reverseJoin = (baseQuery2, joiningQuery) => {
1247
1247
  const foreignAs = pqb.getQueryAs(joiningQuery);
1248
- return joinQuery(baseQuery2, pqb.getQueryAs(baseQuery2), foreignAs, __spreadProps$1(__spreadValues$3({}, baseQuery2.q.joinedShapes), {
1248
+ return joinQuery(baseQuery2, pqb.getQueryAs(baseQuery2), foreignAs, __spreadProps$2(__spreadValues$3({}, baseQuery2.q.joinedShapes), {
1249
1249
  [foreignAs]: joiningQuery.q.shape
1250
1250
  }));
1251
1251
  };
@@ -1275,7 +1275,7 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
1275
1275
  ),
1276
1276
  joinQuery: joinQueryChainingHOF(
1277
1277
  reverseJoin,
1278
- (joiningQuery, baseQuery2) => joinQuery(joiningQuery, pqb.getQueryAs(baseQuery2), pqb.getQueryAs(joiningQuery), __spreadProps$1(__spreadValues$3({}, joiningQuery.q.joinedShapes), {
1278
+ (joiningQuery, baseQuery2) => joinQuery(joiningQuery, pqb.getQueryAs(baseQuery2), pqb.getQueryAs(joiningQuery), __spreadProps$2(__spreadValues$3({}, joiningQuery.q.joinedShapes), {
1279
1279
  [baseQuery2.q.as || baseQuery2.table]: baseQuery2.q.shape
1280
1280
  }))
1281
1281
  ),
@@ -1586,6 +1586,8 @@ const nestedUpdate = (state) => {
1586
1586
  };
1587
1587
 
1588
1588
  var __defProp$2 = Object.defineProperty;
1589
+ var __defProps$1 = Object.defineProperties;
1590
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1589
1591
  var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1590
1592
  var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1591
1593
  var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
@@ -1601,6 +1603,7 @@ var __spreadValues$2 = (a, b) => {
1601
1603
  }
1602
1604
  return a;
1603
1605
  };
1606
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1604
1607
  const applyRelations = (qb, tables, result) => {
1605
1608
  var _a;
1606
1609
  const tableEntries = Object.entries(tables);
@@ -1778,6 +1781,13 @@ const makeRelationQuery = (table, relationName, data, q) => {
1778
1781
  } else {
1779
1782
  query.q.relChain = [this];
1780
1783
  }
1784
+ const aliases = this.q.as ? __spreadValues$2({}, this.q.aliases) : __spreadProps$1(__spreadValues$2({}, this.q.aliases), { [this.table]: this.table });
1785
+ const relAliases = query.q.aliases;
1786
+ for (const as in relAliases) {
1787
+ aliases[as] = pqb._queryResolveAlias(aliases, as);
1788
+ }
1789
+ query.q.as = aliases[query.q.as];
1790
+ query.q.aliases = aliases;
1781
1791
  query.q.joinedShapes = __spreadValues$2({
1782
1792
  [pqb.getQueryAs(this)]: this.q.shape
1783
1793
  }, this.q.joinedShapes);