Enum ResolvedRef
pub enum ResolvedRef<'a> {
Column(&'a Column),
Field(&'a Field),
Model(&'a ModelRoot),
Cte {
nesting: usize,
index: usize,
},
Derived(DerivedRef<'a>),
}Expand description
Result of resolving an ExprReference to its concrete schema location.
When an expression references a field or column (e.g., user.name in a
WHERE clause), the ExprContext::resolve_expr_reference() method returns
this enum to indicate whether the reference points to an application field,
physical table column, or CTE column.
This distinction is important for different processing stages: application fields are used during high-level query building, physical columns during SQL generation, and CTE columns require special handling with generated identifiers based on position.
Variants§
Column(&'a Column)
A resolved reference to a physical database column.
Contains a reference to the actual Column struct with column metadata including name, type, and constraints. Used when resolving ExprReference::Column expressions that point to concrete table columns in the database schema.
Example: Resolving user.name in a query returns Column with name=“name”,
ty=Type::String from the users table schema.
Field(&'a Field)
A resolved reference to an application-level field.
Contains a reference to the Field struct from the application schema, which includes field metadata like name, type, and model relationships. Used when resolving ExprReference::Field expressions that point to model fields before they are lowered to database columns.
Example: Resolving User::name in a query returns Field with name=“name”
from the User model’s field definitions.
Model(&'a ModelRoot)
A resolved reference to a model
Cte
A resolved reference to a Common Table Expression (CTE) column.
Contains the nesting level and column index for CTE references when resolving ExprReference::Column expressions that point to CTE outputs rather than physical table columns. The nesting indicates how many query levels to traverse upward, and index identifies which column within the CTE’s output.
Example: In a WITH clause, resolving a reference to the second column of a CTE defined 1 level up returns Cte { nesting: 1, index: 1 }.
Derived(DerivedRef<'a>)
A resolved reference to a derived table (subquery in FROM clause) column.
Contains the nesting level, column index, and a reference to the derived table itself. This allows consumers to inspect the derived table’s content (e.g., checking VALUES rows for constant values).