pub struct RelationInclude<M: 'static, Rel: 'static, RelPK: 'static> {
pub parent_fk_extract: fn(&M) -> Option<RelPK>,
pub related_descriptor: &'static ModelDescriptor<Rel, RelPK>,
}Expand description
Typed handle for an .include(...) call on a query builder. Carries
everything the runtime needs to issue the side-load query for a
to-one relation: a function pointer that extracts the FK value from
a parent row, and a static descriptor of the related model.
Built by the macro-emitted <model_module>::<relation_name>()
accessor — see the .include(...) builder method on FindMany.
Scope (v1): to-one relations only, where the related target column is the related model’s primary key. Non-PK references and to-many relations are out of scope for this release; the macro silently omits accessors for non-PK references, and to-many relations stay on the existing list-side query path.
Fields§
§parent_fk_extract: fn(&M) -> Option<RelPK>Extracts the FK value from a parent row. None ⇒ the parent’s
FK column is null, so there’s no related row to load. Function
pointers (not closures) by design: keep the type cheap to copy
and ensure call sites can’t smuggle in captures that outlive
the descriptor’s 'static.
The related model’s descriptor. The runtime uses this to drive
the side-load query (SELECT projection FROM related WHERE related.pk IN (...)) so the related-side read policy still
applies.