orchid-orm 1.50.3 → 1.50.5

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.mjs CHANGED
@@ -89,7 +89,7 @@ function createBaseTable({
89
89
  setColumns(fn, dataFn) {
90
90
  columnTypes[snakeCaseKey] = this.snakeCase;
91
91
  const shape = getColumnTypes(columnTypes, fn, nowSQL, this.language);
92
- const tableData = this.constructor.prototype.tableData = parseTableData(dataFn);
92
+ const tableData = parseTableData(dataFn);
93
93
  if (this.snakeCase) {
94
94
  for (const key in shape) {
95
95
  const column = shape[key];
@@ -148,10 +148,10 @@ function createBaseTable({
148
148
  }
149
149
 
150
150
  const getThroughRelation = (table, through) => {
151
- return table.relations[through]?.relationConfig;
151
+ return table.relations[through];
152
152
  };
153
153
  const getSourceRelation = (throughRelation, source) => {
154
- return throughRelation.query.relations[source]?.relationConfig;
154
+ return throughRelation.query.relations[source];
155
155
  };
156
156
  const hasRelationHandleCreate = (q, ctx, item, rowIndex, key, primaryKeys, nestedInsert) => {
157
157
  const value = item[key];
@@ -297,7 +297,8 @@ const joinQueryChainHOF = (relPKeys, reverseJoin, joinQuery) => (joiningQuery, b
297
297
  return joinQuery(jq, baseQuery);
298
298
  }
299
299
  const last = chain[chain.length - 1];
300
- const query = "relationConfig" in last ? last.relationConfig.joinQuery(last, baseQuery) : last;
300
+ const prev = chain[chain.length - 2];
301
+ const query = prev.rel.joinQuery(last.query, baseQuery);
301
302
  let useWhereExist = true;
302
303
  if (jq.q.returnType !== "value" && jq.q.returnType !== "valueOrThrow") {
303
304
  let tablePrefix;
@@ -1958,7 +1959,7 @@ const applyRelations = (qb, tables, result) => {
1958
1959
  let message = `Cannot define a \`${item.relationName}\` relation on \`${as}\``;
1959
1960
  const table = result[as];
1960
1961
  const { through, source } = relation.options;
1961
- const throughRel = table.relations[through]?.relationConfig;
1962
+ const throughRel = table.relations[through];
1962
1963
  if (through && !throughRel) {
1963
1964
  message += `: cannot find \`${through}\` relation required by the \`through\` option`;
1964
1965
  } else if (source && throughRel && !throughRel.table.relations[source]) {
@@ -2033,7 +2034,7 @@ const applyRelation = (table, qb, { relationName, relation, dbTable, otherDbTabl
2033
2034
  return q;
2034
2035
  }
2035
2036
  };
2036
- baseQuery.relationConfig = {
2037
+ dbTable.relations[relationName] = {
2037
2038
  table: otherDbTable,
2038
2039
  query,
2039
2040
  queryRelated: data.queryRelated,
@@ -2041,7 +2042,7 @@ const applyRelation = (table, qb, { relationName, relation, dbTable, otherDbTabl
2041
2042
  reverseJoin: data.reverseJoin,
2042
2043
  modifyRelatedQuery: data.modifyRelatedQuery
2043
2044
  };
2044
- dbTable.relations[relationName] = query;
2045
+ (dbTable.relationQueries ?? (dbTable.relationQueries = {}))[relationName] = query;
2045
2046
  const tableRelations = delayedRelations.get(dbTable);
2046
2047
  if (!tableRelations) return;
2047
2048
  tableRelations[relationName]?.forEach((data2) => {
@@ -2140,7 +2141,7 @@ const orchidORM = ({
2140
2141
  table.types,
2141
2142
  transactionStorage,
2142
2143
  options2,
2143
- table.constructor.prototype.tableData ?? {}
2144
+ table.constructor.prototype.columns?.data ?? {}
2144
2145
  );
2145
2146
  dbTable.definedAs = key;
2146
2147
  dbTable.db = result;