orchid-orm 1.10.3 → 1.10.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.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -163,7 +163,7 @@ const makeBelongsToMethod = (relation, relationName, query) => {
|
|
|
163
163
|
return {
|
|
164
164
|
returns: "one",
|
|
165
165
|
method: (params) => {
|
|
166
|
-
return query.
|
|
166
|
+
return query.where({ [primaryKey]: params[foreignKey] });
|
|
167
167
|
},
|
|
168
168
|
virtualColumn: new BelongsToVirtualColumn(relationName, state),
|
|
169
169
|
joinQuery(fromQuery, toQuery) {
|
|
@@ -397,11 +397,6 @@ class HasOneVirtualColumn extends pqb.VirtualColumn {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
const makeHasOneMethod = (table, relation, relationName, query) => {
|
|
400
|
-
if (relation.options.required) {
|
|
401
|
-
query._take();
|
|
402
|
-
} else {
|
|
403
|
-
query._takeOptional();
|
|
404
|
-
}
|
|
405
400
|
if ("through" in relation.options) {
|
|
406
401
|
const { through, source } = relation.options;
|
|
407
402
|
const throughRelation = getThroughRelation(table, through);
|
|
@@ -1265,7 +1260,11 @@ const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, de
|
|
|
1265
1260
|
throw new Error(`Unknown relation type ${type}`);
|
|
1266
1261
|
}
|
|
1267
1262
|
if (data.returns === "one") {
|
|
1268
|
-
|
|
1263
|
+
if (relation.options.required) {
|
|
1264
|
+
query._take();
|
|
1265
|
+
} else {
|
|
1266
|
+
query._takeOptional();
|
|
1267
|
+
}
|
|
1269
1268
|
query.query.returnsOne = true;
|
|
1270
1269
|
}
|
|
1271
1270
|
if (data.virtualColumn) {
|