Skip to content

spec(relations): manyToMany materialises the intermediate entity - #19

Open
delchev wants to merge 1 commit into
mainfrom
spec/many-to-many-materialisation
Open

spec(relations): manyToMany materialises the intermediate entity#19
delchev wants to merge 1 commit into
mainfrom
spec/many-to-many-materialisation

Conversation

@delchev

@delchev delchev commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

What

kind: manyToMany was parsed and materialised by nothing — a clean parse and a relationship that is simply absent from the generated application. This specifies the materialisation instead of the silent drop.

An n:m has always been an intermediate (link) entity in this spec. Now the kind that names it writes that entity:

  • link entity <Declaring><Target> — or the name given by the new through: attribute — with a generated integer key, a composition to the declaring side and a manyToOne to the target (cross-model allowed via model:);
  • the authored relation becomes the navigation-only oneToMany to the link, so the document holds exactly one representation of an n:m;
  • the link is a real entity: its own table, a detail grid with a dropdown under the declaring entity, seedable and reportable.

The explicit intermediate entity keeps its place and gains a clear boundary: it is how a link that carries data of its own (a quantity, a partial amount, a valid-from date) is authored — then the manyToMany is dropped.

Also specified: declare an n:m on one side only; which relation attributes travel onto the link's target end (where / show / major / size / leafOnly) and which are refused rather than ignored (composition, function, init, dependsOn, calculated actions, personal, partner); through: validity and the name-collision rule; the self-referencing case.

Pages

  • docs/spec/relations.md — the Many-to-many section rewritten (materialised link + explicit intermediate entity).
  • docs/reference.md — "Planned" entry replaced: what remains unimplemented is bridge fields on a generated link, not the kind itself; through: added to the attribute examples.

An n:m has always been an intermediate (link) entity in this specification; the
kind that named it was parsed and then materialised by nothing, which is the worst
of the three possible states - a clean parse and a relationship that simply is not
there.

Specify the materialisation: `kind: manyToMany` writes the link entity
<Declaring><Target> (or the relation's `through:`) with a generated key, a
composition to the declaring side and a manyToOne to the target (cross-model
allowed), and the authored relation becomes the navigation-only oneToMany to it -
so the document holds exactly one representation of an n:m. The link is a real
entity: table, detail grid with a dropdown, seedable, reportable.

The explicit intermediate entity keeps its place, and gains a clear boundary: it
is how a link that carries data of its own (a quantity, a partial amount, a
valid-from) is authored. Also specified: one-sided declaration, which relation
attributes travel to the link's target end and which are refused rather than
ignored, the through:/name-collision rules, and the self-referencing case.
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.

1 participant