@zenstackhq/orm 3.0.0-beta.31 → 3.0.0-beta.32
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.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -432,15 +432,16 @@ function getManyToManyRelation(schema, model, field) {
|
|
|
432
432
|
if (!fieldDef.array || !fieldDef.relation?.opposite) {
|
|
433
433
|
return void 0;
|
|
434
434
|
}
|
|
435
|
+
const realModel = fieldDef.originModel ?? model;
|
|
435
436
|
const oppositeFieldDef = requireField(schema, fieldDef.type, fieldDef.relation.opposite);
|
|
436
437
|
if (oppositeFieldDef.array) {
|
|
437
438
|
const sortedModelNames = [
|
|
438
|
-
|
|
439
|
+
realModel,
|
|
439
440
|
fieldDef.type
|
|
440
441
|
].sort();
|
|
441
442
|
let orderedFK;
|
|
442
|
-
if (
|
|
443
|
-
orderedFK = sortedModelNames[0] ===
|
|
443
|
+
if (realModel !== fieldDef.type) {
|
|
444
|
+
orderedFK = sortedModelNames[0] === realModel ? [
|
|
444
445
|
"A",
|
|
445
446
|
"B"
|
|
446
447
|
] : [
|
|
@@ -460,7 +461,7 @@ function getManyToManyRelation(schema, model, field) {
|
|
|
460
461
|
"A"
|
|
461
462
|
];
|
|
462
463
|
}
|
|
463
|
-
const modelIdFields = requireIdFields(schema,
|
|
464
|
+
const modelIdFields = requireIdFields(schema, realModel);
|
|
464
465
|
(0, import_common_helpers.invariant)(modelIdFields.length === 1, "Only single-field ID is supported for many-to-many relation");
|
|
465
466
|
const otherIdFields = requireIdFields(schema, fieldDef.type);
|
|
466
467
|
(0, import_common_helpers.invariant)(otherIdFields.length === 1, "Only single-field ID is supported for many-to-many relation");
|