You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(contract-psl): synthesise a model-less junction for implicit M:N
When both navigable list ends are bare (no `through:`) and no junction
model links the pair, the PSL interpreter now synthesises a model-less
junction table (Prisma's implicit many-to-many) instead of emitting the
orphaned-backrelation diagnostic.
Detection lives in `applyBackrelationCandidates`: a bare list with no
FK-side match, no authored junction, and no junction near-miss is deferred
to `resolveImplicitManyToMany`, which pairs it with its mirror end (or
resolves a self-referential list on its own) and emits the `N:M`/`through`
descriptor on both ends. D5 precedence is preserved — a both-bare pair
with an authored junction model is still recognised, never synthesised.
Synthesis injects a junction `ModelNode` named `_<A>To<B>` (terminal model
names ordered alphabetically) with foreign-key columns `A` and `B` (A
references the first model's id, B the second), a composite `(A, B)`
identity, and the two foreign keys; the contract assembler turns it into a
storage table and fills the through descriptors' `targetColumns` from the
terminal ids. The junction is a physical table only — filtered out of
`roots` like an STI variant.
Diagnostics: a terminal without a single-column `@id`
(`PSL_IMPLICIT_MN_TARGET_NO_ID`), more than one implicit many-to-many
between the same pair (`PSL_IMPLICIT_MN_AMBIGUOUS`), and a real table
already named like the synthesised junction
(`PSL_IMPLICIT_MN_NAME_COLLISION`).
Migration DDL and runtime `include` integration are S4·M2.
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
0 commit comments