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.
Param
A positional query parameter $N (0-based index internally).
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))
AggOverQuery
An aggregate function applied to a full SELECT query: count(Person) or count((select Person)).
Emits: (SELECT fn_name(*) FROM (inner) _agg)
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”).
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.
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.
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
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
ForVar
Reference to the current for-loop iterator variable.
Emits "_for_{name}"."v".
Fields
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".
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).
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>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.
GlobalRef
Computed global reference: emits (SELECT "value" FROM "cte_name").
Subscript
Index access expr[i]: substr(expr, i+1, 1) for strings/bytes, (expr)[i+1] for arrays.
JsonbField
Named tuple / jsonb field access: (expr)->'field' (returns jsonb).
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).
Slice
Slice access expr[lower:upper]: substr for strings/bytes, PG subscript for arrays.
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".
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§
Auto Trait Implementations§
impl Freeze for IrExpr
impl RefUnwindSafe for IrExpr
impl Send for IrExpr
impl Sync for IrExpr
impl Unpin for IrExpr
impl UnsafeUnpin for IrExpr
impl UnwindSafe for IrExpr
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.