Description
@tshedor I will try to summarize my issue as much as I can though I must accept that I might have skill issue regarding brick I apologize for that:
Question:
I might be experiencing some challenges regarding how Brick handles one-to-many relationships. I'll summarize the issue and my expectations to make it clear:
Context
I have two models:
- Model A
- Model B
Model B contains a list of Model A objects (
List<A>
), and Model A has ab_id
field that acts as a foreign key referencing theid
of Model B in Supabase. The database schema ensures thatb_id
is properly set up as a foreign key.Expectations
When querying for an instance of Model B using Brick (e.g.,
repository.get<B>()
), I expect the resulting object to automatically include the associatedList<A>
. This means that each Model B should be populated with its related Model A instances.Observation
This expectation is not consistently met. Specifically:
- If I query Model B without any condition (e.g.,
repository.get<B>()
), the associatedList<A>
is sometimes populated correctly.- However, in other cases, especially with queries involving conditions or filters, the relationship does not seem to resolve, and the
List<A>
is left empty or incomplete.Request
I would like to understand:
- How Brick handles one-to-many relationships when querying models, particularly in the context of foreign keys.
- Whether this behavior is expected or if there might be a misconfiguration in my models or repository setup.
- Any recommended steps to ensure that querying Model B reliably includes the associated
List<A>
objects.
Originally posted by @richard457 in #528