tempest-framework icon indicating copy to clipboard operation
tempest-framework copied to clipboard

Missing M:N relations in ORM/Query builder

Open asakurayoh opened this issue 5 months ago • 3 comments

Description

The is N:1, 1:N and 1:1 relation, but no N:M relation. Possibility to add re condition to retrieve only some of the relation (ex, type of the relation) and retrieve data saved on the middle table. Here my example:

movie

  • id
  • title
  • actors
  • screenwriters

people

  • id
  • name

movie_person

  • id
  • movie_id
  • person_id
  • type (ex: actor, sreenwriter)
  • role

So the movie can have many person that are of type "actor", with a role information (can have many of the same actor on the same movie, with different role), and many person of type "screenwriter" without role.

Is there already a way to do it (can't find it).

Or what would be a good way to do it without much db queries. (the mapper is still a bit of a mystery, the doc is really light on how it work).

Thanks.

Benefits

Possibility to use M:N relations easily.

asakurayoh avatar Aug 12 '25 02:08 asakurayoh

For now, you must manually create and query the relation model. We'll keep this issue around and I'll work on it after #1458 is merged

brendt avatar Aug 12 '25 05:08 brendt

Hey @brendt I'm still checking some things out, so I won't say 100% I'll get this to work on it. But I'm experimenting and trying some stuff here. If things go well, I'll have a draft PR to start discussion around this. IDK if you want to assign this to me already, or want to wait until I see if I manage to have this draft PR.

WendellAdriel avatar Aug 18 '25 13:08 WendellAdriel

I just created this draft PR to start a discussion on how this should be implemented, @brendt: #1525 If you want to, you can assign this issue to me, and I can continue with the implementation for this.

WendellAdriel avatar Aug 18 '25 15:08 WendellAdriel