@famgia/omnify-laravel 0.0.112 → 0.0.113

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.
@@ -566,7 +566,29 @@ function extractManyToManyRelations(schema, allSchemas) {
566
566
  const targetSchema = allSchemas[targetName];
567
567
  const targetTable = toTableName(targetName);
568
568
  const targetPkType = targetSchema ? getIdType(targetSchema) : "BigInt";
569
- const isOwningSide = assocProp.owning ?? schema.name < targetName;
569
+ let isOwningSide;
570
+ if (assocProp.owning !== void 0) {
571
+ isOwningSide = assocProp.owning;
572
+ } else if (assocProp.pivotFields && Object.keys(assocProp.pivotFields).length > 0) {
573
+ isOwningSide = true;
574
+ } else {
575
+ let targetHasMappedByToThisSide = false;
576
+ if (targetSchema?.properties) {
577
+ for (const [, targetProp] of Object.entries(targetSchema.properties)) {
578
+ if (targetProp.type !== "Association") continue;
579
+ const targetAssoc = targetProp;
580
+ if (targetAssoc.relation === "ManyToMany" && targetAssoc.target === schema.name && targetAssoc.mappedBy) {
581
+ targetHasMappedByToThisSide = true;
582
+ break;
583
+ }
584
+ }
585
+ }
586
+ if (targetHasMappedByToThisSide) {
587
+ isOwningSide = true;
588
+ } else {
589
+ isOwningSide = schema.name < targetName;
590
+ }
591
+ }
570
592
  if (!isOwningSide) {
571
593
  continue;
572
594
  }
@@ -4817,4 +4839,4 @@ export {
4817
4839
  shouldGenerateAIGuides,
4818
4840
  laravelPlugin
4819
4841
  };
4820
- //# sourceMappingURL=chunk-GDFAEEEG.js.map
4842
+ //# sourceMappingURL=chunk-3YANFHE5.js.map