ResolvedRef

Enum ResolvedRef 

Source
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 }.

Fields

§nesting: usize
§index: usize
§

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).

Implementations§

Source§

impl<'a> ResolvedRef<'a>

Source

pub fn expect_column(self) -> &'a Column

Source

pub fn expect_field(self) -> &'a Field

Source

pub fn expect_model(self) -> &'a ModelRoot

Trait Implementations§

Source§

impl<'a> Debug for ResolvedRef<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ResolvedRef<'a>

§

impl<'a> RefUnwindSafe for ResolvedRef<'a>

§

impl<'a> Send for ResolvedRef<'a>

§

impl<'a> Sync for ResolvedRef<'a>

§

impl<'a> Unpin for ResolvedRef<'a>

§

impl<'a> UnwindSafe for ResolvedRef<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V