Skip to main content

IrExpr

Enum IrExpr 

Source
pub enum IrExpr {
Show 37 variants ColumnRef { alias: String, column: String, pg_type: String, }, Param { index: usize, }, Literal(IrLiteral), BinOp(Box<IrBinOp>), UnaryOp(Box<IrUnaryOp>), FunctionCall(IrFunctionCall), TypeCast(Box<IrTypeCast>), IfElse(Box<IrIfElse>), Subquery(Box<IrSelect>), Array(Vec<IrExpr>), Null, AggOverSet { fn_name: String, schema: Option<String>, elems: Vec<IrExpr>, }, AggOverQuery { fn_name: String, inner: Box<IrSelect>, }, AggOverCte { fn_name: String, cte: String, column: Option<String>, }, ExistsOverCte { cte: String, column: Option<String>, }, SetOp { op: SetOpKind, left: Box<IrExpr>, right: Box<IrExpr>, mode: SetOpMode, }, CteRef { name: String, scalar: bool, pg_type: Option<String>, }, CteFieldRef { name: String, field: String, pg_type: Option<String>, }, ForVar { name: String, pg_type: Option<String>, }, ArrayFromSelect(Box<IrArraySource>), ScalarSubquery(Box<IrSelect>), EnumLiteral { pg_type: String, variant: String, }, NamedTuple { fields: Vec<(String, IrExpr)>, is_free_object: bool, }, ObjectPathUnion { branches: Vec<IrPathSelect>, limit: Option<Box<IrExpr>>, multi: bool, }, ObjectPathSubquery(Box<IrPathSelect>), ObjectSubquery(Box<IrSelect>), Tuple(Vec<IrExpr>), GlobalParam { index: usize, pg_type: String, }, GlobalRef { cte_name: String, }, Subscript { expr: Box<IrExpr>, index: Box<IrExpr>, is_array: bool, }, JsonbField { expr: Box<IrExpr>, field: String, }, JsonbIndex { expr: Box<IrExpr>, index: usize, }, Slice { expr: Box<IrExpr>, lower: Option<Box<IrExpr>>, upper: Option<Box<IrExpr>>, is_array: bool, }, FnSubquery(Box<IrFunctionSelect>), PathSubquery(Box<IrPathSelect>), FnParam { name: String, pg_type: String, }, RawSql(String),
}

Variants§

§

ColumnRef

A resolved column reference, e.g. t0.name.

Fields

§alias: String
§column: String
§pg_type: String
§

Param

A positional query parameter $N (0-based index internally).

Fields

§index: usize
§

Literal(IrLiteral)

§

BinOp(Box<IrBinOp>)

§

UnaryOp(Box<IrUnaryOp>)

§

FunctionCall(IrFunctionCall)

§

TypeCast(Box<IrTypeCast>)

§

IfElse(Box<IrIfElse>)

§

Subquery(Box<IrSelect>)

A scalar subquery (used for computed pointers that are themselves selects).

§

Array(Vec<IrExpr>)

An array literal: [1, 2, 3].

§

Null

The empty set {} used as an assignment value — emits SQL NULL.

§

AggOverSet

An aggregate function applied to an inline set literal fn({e1, e2, ...}). Emits: (SELECT fn_name(v) FROM (SELECT e1 UNION ALL ...) AS _set(v))

Fields

§fn_name: String
§schema: Option<String>
§elems: Vec<IrExpr>
§

AggOverQuery

An aggregate function applied to a full SELECT query: count(Person) or count((select Person)). Emits: (SELECT fn_name(*) FROM (inner) _agg)

Fields

§fn_name: String
§inner: Box<IrSelect>
§

AggOverCte

An aggregate applied to a whole with binding: count(memberships). Emits: (SELECT fn_name(column) FROM "cte"), column being * for an object binding and the scalar column for a scalar one. Read through CteRef instead, a binding holding more than one row aborts the query (“more than one row returned by a subquery used as an expression”).

Fields

§fn_name: String
§column: Option<String>
§

ExistsOverCte

exists memberships over a whole with binding. Emits EXISTS(SELECT 1 FROM "cte"), restricted to a non-null column for a scalar binding, whose single-value form holds a NULL row when empty. Read through CteRef instead, a binding of more than one row aborts the query the same way AggOverCte describes.

Fields

§column: Option<String>
§

SetOp

array_unpack(a) intersect array_unpack(b) — a set operation between two set-valued expressions. Emits the array of what it yields, or EXISTS over it when that is all the caller wanted.

Fields

§left: Box<IrExpr>
§right: Box<IrExpr>
§

CteRef

A reference to a named CTE used in expression context. scalar = true → emits (SELECT "result" FROM "cte_name") scalar = false → emits (SELECT "id" FROM "cte_name")

Fields

§name: String
§scalar: bool
§pg_type: Option<String>

The bound value’s PostgreSQL type when it is a scalar, so overload resolution and operator type-checking can see through the binding — without it, contains(xs, 'a') over a with-bound value matched no overload and needed an explicit cast.

§

CteFieldRef

A single-field access on a WITH-bound free object: with x := { a := 1 } select x.a. The CTE body exposes each free-object field as its own named column (alongside the whole-object result column CtePassthrough/CteRef use) so this can reference it directly rather than reconstructing/decoding the opaque result composite. Emits (SELECT "field" FROM "name").

Fields

§name: String
§field: String
§pg_type: Option<String>

The field’s PostgreSQL type, so a call over x.a resolves the same overload a call over the value bound to a would.

§

ForVar

Reference to the current for-loop iterator variable. Emits "_for_{name}"."v".

Fields

§name: String
§pg_type: Option<String>

The type of one iteration’s value — the iterator’s element type, or uuid for a loop over objects, whose variable holds the row key. Carried for the same reason CteFieldRef carries one.

§

ArrayFromSelect(Box<IrArraySource>)

ARRAY(SELECT scalar FROM source [JOINs] [WHERE filter]). Used as the array argument to _pylon.assert_single/exists/distinct.

§

ScalarSubquery(Box<IrSelect>)

A free SELECT read for its single value — (select count(Visit) filter …) in expression position. Inline rather than a CTE because the inner statement may read the enclosing row, which nothing ahead of the FROM clause can see.

§

EnumLiteral

An enum member access: default::Gender.Female → 'Female'::"default"."Gender".

Fields

§pg_type: String
§variant: String
§

NamedTuple

Named tuple construction: (x := 1.0, y := 2.0) → jsonb_build_object('x', 1.0, 'y', 2.0). is_free_object is true when this actually came from { x := 1.0 } (curly-brace shape syntax, no subject) rather than (x := 1.0) (paren tuple syntax) — same jsonb encoding/decoding either way, but the frontend needs to know which one it was to render an expandable Object {x: 1.0} vs a (x := 1.0) literal display correctly (see ShapeNode::NamedTuple’s own is_free_object).

Fields

§fields: Vec<(String, IrExpr)>
§is_free_object: bool
§

ObjectPathUnion

Several correlated walks read as one set – (.<prices[is Listing] union .<sale_prices[is Listing]) { id }. Each branch hangs off the enclosing row, so none of them can be hoisted into a CTE of its own the way a standalone union’s operands are.

Fields

§branches: Vec<IrPathSelect>
§multi: bool

True when the operands reach many objects, so the arms are aggregated to an array instead of being read as one record – a scalar subquery over more than one row is a run-time error.

§

ObjectPathSubquery(Box<IrPathSelect>)

The object a single-valued walk lands on, with its shape — the path-select twin of ObjectSubquery. PathSubquery over the same walk gives the object’s id, which is what a path in plain expression position means; this is for a pointer that asked for the object.

§

ObjectSubquery(Box<IrSelect>)

An object, with its shape, standing as a value — a free object’s object-valued field ({ device := d { id } }). A free shape is a real object type whose fields are real pointers, so an object field stays an object rather than degrading to its id; this is the same composite row a single link emits, just uncorrelated.

§

Tuple(Vec<IrExpr>)

Positional tuple construction: (1, 'x') → jsonb_build_array(1, 'x').

§

GlobalParam

Session global: emits $N::pg_type directly. The parameter slot carries the __global__ prefix.

Fields

§index: usize
§pg_type: String
§

GlobalRef

Computed global reference: emits (SELECT "value" FROM "cte_name").

Fields

§cte_name: String
§

Subscript

Index access expr[i]: substr(expr, i+1, 1) for strings/bytes, (expr)[i+1] for arrays.

Fields

§expr: Box<IrExpr>
§index: Box<IrExpr>
§is_array: bool
§

JsonbField

Named tuple / jsonb field access: (expr)->'field' (returns jsonb).

Fields

§expr: Box<IrExpr>
§field: String
§

JsonbIndex

Positional tuple index into a jsonb array: (expr)->index (returns jsonb). Runtime fallback for .N tuple indexing when expr isn’t a literal tuple constant-foldable at compile time (e.g. a $param or cast result).

Fields

§expr: Box<IrExpr>
§index: usize
§

Slice

Slice access expr[lower:upper]: substr for strings/bytes, PG subscript for arrays.

Fields

§expr: Box<IrExpr>
§is_array: bool
§

FnSubquery(Box<IrFunctionSelect>)

An object-returning user function projected down to one of its columns: (SELECT alias."col" FROM module.fn(args) AS alias …). shape always holds exactly one pointer — the projected column — which is what makes an otherwise object-valued call usable inside a larger expression.

§

PathSubquery(Box<IrPathSelect>)

Detached path as a scalar subquery: (SELECT scalar FROM root [JOINs]). Used when detached TypeName.prop appears in a schema-bound expression context.

§

FnParam

A named parameter reference inside a user-defined function body. Emitted as a double-quoted SQL identifier: "param_name".

Fields

§name: String
§pg_type: String
§

RawSql(String)

Verbatim SQL text, emitted parenthesized exactly as given. Never produced by ordinary PyQL compilation — only used to substitute an INSERT rewrite’s self-reference (.name) to a property that has no explicit assignment in this statement with that property’s own default_sql, the same value Postgres’s column DEFAULT would have produced. A plain INSERT ... VALUES (...) has no FROM-clause for a real ColumnRef to resolve against (confirmed live — “missing FROM-clause entry”), unlike UPDATE’s SET clause, which can reference the table’s own alias validly, so this substitution is INSERT-only.

Trait Implementations§

Source§

impl Clone for IrExpr

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IrExpr

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more