fields
fields( rel: Relationship | Chain, *, include_owner: bool = False) -> tuple[FieldRef, ...]Return selectable FieldRef objects for rel’s fields.
This bridges introspection and live DSL usage: the returned
FieldRef objects can be passed directly to select.
By default the owner concept’s field is excluded — specifically, the
first field, when its type matches the owning concept. For chain
access (Person.name), the owner is the chain’s root. For a direct
Relationship or Reading handle, the owner is inferred
from the model: if exactly one concept in model.concepts owns the
relationship (via _relationships or _identify_by), that concept
is the owner. If ownership is ambiguous (the same relationship is
attached to multiple concepts) or standalone (bare relationship), all
fields are returned. Pass include_owner=True to always return all
fields.
Parameters
(relRelationship|Chain) - A relationship or chain to inspect.
(include_ownerbool, default:False) - If True, include the owner concept’s field in the result.
Returns
tuple[FieldRef,…] - Field references, usable inselect.
Examples
from relationalai.semantics import Model, String, Any, inspect
m = Model("example")Item = m.Concept("Item")Item.successors = m.Relationship(f"{Item:i} has successor {Item:s} with {Any:data}")refs = inspect.fields(Item.successors)len(refs) # excludes the owner 'i' field# 2