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