Skip to main content

Module relation_chain

Module relation_chain 

Source
Expand description

Chain relation methods on a Many handle to traverse multi-step associations without declaring a via relation on the schema.

user.todos().category() produces an Association whose path is two steps long (User → todos → category). The query engine lowers this by unfolding into nested IN-subqueries against the outermost relation.

Modules§

chain_dedupes_when_todos_share_category
chain_from_empty_source_is_empty
chain_scopes_per_starting_user
chain_then_filter
user_todos_category

Functions§

chain_skips_null_belongs_to
BelongsTo<Option<_>> in the chain skips NULL foreign keys. Todos with no category contribute nothing to the chain.
four_step_chain
A 4-step chain (Org → Team → Project → Issue → Tag) drives the peel_first_step loop through three iterations before reducing to a single-step rewrite. Guards against regressions in the depth-independent part of the unfolder.
has_many_through_has_many
Two HasMany hops in succession (Author → posts → comments). The lowering unfolds into nested IN-subqueries on each BelongsTo pair.
three_step_chain
A 3-step chain (User → Project → Task → Tag) walks the planner’s unfolder more than once. Verifies the recursive nesting and the chain of BelongsTo rewrites at each hop.