orchid-orm 1.9.11 → 1.9.12
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 +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1225,7 +1225,9 @@ const delayRelation = (delayedRelations, table, relationName, data) => {
|
|
|
1225
1225
|
};
|
|
1226
1226
|
const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, delayedRelations) => {
|
|
1227
1227
|
var _a;
|
|
1228
|
-
const
|
|
1228
|
+
const baseQuery = Object.create(otherDbTable);
|
|
1229
|
+
baseQuery.baseQuery = baseQuery;
|
|
1230
|
+
const query = (relation.options.scope ? relation.options.scope(baseQuery) : baseQuery).as(relationName);
|
|
1229
1231
|
const definedAs = query.definedAs;
|
|
1230
1232
|
if (!definedAs) {
|
|
1231
1233
|
throw new Error(
|
|
@@ -1258,6 +1260,7 @@ const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, de
|
|
|
1258
1260
|
dbTable.shape[relationName] = dbTable.query.shape[relationName] = data.virtualColumn;
|
|
1259
1261
|
}
|
|
1260
1262
|
makeRelationQuery(dbTable, definedAs, relationName, data);
|
|
1263
|
+
baseQuery.joinQuery = data.joinQuery;
|
|
1261
1264
|
dbTable.relations[relationName] = {
|
|
1262
1265
|
type,
|
|
1263
1266
|
key: relationName,
|
|
@@ -1267,6 +1270,7 @@ const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, de
|
|
|
1267
1270
|
primaryKey: data.primaryKey,
|
|
1268
1271
|
options: relation.options
|
|
1269
1272
|
};
|
|
1273
|
+
dbTable.relationsQueries[relationName] = query;
|
|
1270
1274
|
const tableRelations = delayedRelations.get(dbTable);
|
|
1271
1275
|
if (!tableRelations)
|
|
1272
1276
|
return;
|