Skip to content

Do not rely on derived pragmas to export relations + keep order of ore-many relations - #131

Merged
jecisc merged 7 commits into
moosetechnology:developmentfrom
jecisc:export
Sep 28, 2026
Merged

jecisc merged 7 commits into
moosetechnology:developmentfrom
jecisc:export

Conversation

@jecisc

@jecisc jecisc commented Sep 25, 2026

Copy link
Copy Markdown
Member

The Fame exporter is exporting one side of a relation usually by using the derived pragmas. But this is not necessary because it pushes to the developer doing the MM the responsibility to make the export work while this should be the work of the exporter.

Also, in case of one-many relation, in most places of Famix we export the one side of the relation but this cause a lost of order in the multiple side.

I changed that. Relations are exported at most once, whatever their multiplicity:

  • A one-to-one relation is serialized when the second entity of the relation is exported; the first side is skipped to avoid dangling references on import.
  • A one-to-many relation is serialized only on its many side to preserve the order of entities in the many side
  • A many-to-many relation is serialized on the side whose name sorts before its opposite's. This keeps the choice deterministic and independent of the export order. A self-opposite many-to-many relation has no such side to choose from and is exported on both sides.

The derived pragma is ignored on relations: a relation is exported according to these rules whatever its derived status. Only derived properties without an opposite (computed attributes) are still filtered out. Using derived on relations is deprecated and will be removed in a future step.

In future steps we plan to:

  • remove the derived pragma from generated relation accessors and from the manual model code, and
  • deprecate the use of the derived pragma for relations when building a Fame metamodel.

@jecisc

jecisc commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

Linked PR: moosetechnology/Famix#1155

@badetitou badetitou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have minor comment that should not block this MR but if you have time please consider them before any merge

Comment thread src/Fame-Core/FM3Property.class.st Resolved
Comment on lines +188 to +196

"A one-to-many relation is exported only on its many side: when we are on the single-valued side, it is never serialized."
(property isOneToManyRelation and: [ property isMultivalued not ]) ifTrue: [ ^ false ].

"A many-to-many relation is serialized only on one side: the one whose name sorts before its opposite's. This avoids exporting the same relation twice while keeping the decision deterministic and independent of the export order."
(property isManyToManyRelation and: [ property name > property opposite name ]) ifTrue: [ ^ false ].

"A one-to-one relation is exported when exporting the second entity of the relation to avoid futurs during import."
(property isOneToOneRelation and: [ (exportedEntities includes: values anyOne) not ]) ifTrue: [ ^ false ].

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these lines could go before line

values isEmptyOrNil ifTrue: [ ^ false ].

Since it concerns the property state and not its values.

I understand shouldIgnoreProperty: could be updated in a later stage for the full update to process

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was keeping this line before since I think it will exit faster in most cases. We have a ton of empty collections and nil values. So I though I'd keep the fastest exit first.

I'll merge like this and we can update it later if you really prefer it after

Co-authored-by: Benoit Verhaeghe <benoit@badetitou.fr>
@jecisc
jecisc merged commit a0ca56a into moosetechnology:development Sep 28, 2026
5 checks passed
@jecisc
jecisc deleted the export branch September 28, 2026 11:46
jecisc added a commit to moosetechnology/Famix that referenced this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants