casekit / orm

1 stars 1 forks source link

Improve the way we specify/typecheck N:N relations #35

Open rsslldnphy opened 5 months ago

rsslldnphy commented 5 months ago

Currently it's possible to define an N:N relation without defining the 1:N and N:1 relations between its two halves and the join table - but if you do so, you'll get a runtime error saying that both sides must be defined.

Technically we have enough info in just the N:N declaration to not need this, but it would make the code much more complicated (I think!) to do so. It's much easier relying on the existence of the other relations so we can reuse the code for fetching them.

However this isn't a great experience and so it would be good to improve it. Either by:

a) removing the requirement for both sides of the N:N relation to be defined b) typechecking at some point to ensure they're both defined (this would likely have to happen at the point of call of the orm function, as we wouldn't have the info we need at the point the relations are initially defined)

rsslldnphy commented 5 months ago

just been v confused by an N:N relation so would be really great to figure something out here