pub enum SqlExpr {
Show 23 variants
Lit(LitValue),
JsonPath {
root: String,
path: JsonPath,
},
Param(usize),
ColRef(String),
Cast {
inner: Box<SqlExpr>,
ty: SqlType,
},
BinOp {
op: BinOp,
lhs: Box<SqlExpr>,
rhs: Box<SqlExpr>,
},
UnaryOp {
op: UnaryOp,
inner: Box<SqlExpr>,
},
Case {
arms: Vec<(SqlExpr, SqlExpr)>,
else_: Option<Box<SqlExpr>>,
},
Coalesce(Vec<SqlExpr>),
NullIf(Box<SqlExpr>, Box<SqlExpr>),
AsJson(Box<SqlExpr>),
JsonAgg(Box<SubQuery>),
Scalar(Box<SubQuery>),
Exists(Box<SubQuery>),
CountSub(Box<SubQuery>),
Alias {
name: String,
inner: Box<SqlExpr>,
},
ReferenceKey {
reference: Box<SqlExpr>,
expected_type: Option<String>,
},
Boundary {
side: BoundarySide,
kind: BoundaryKind,
source: Box<SqlExpr>,
},
WhereExists {
focus: Box<SqlExpr>,
iter_alias: String,
predicate: Box<SqlExpr>,
negate: bool,
},
WhereScalar {
focus: Box<SqlExpr>,
iter_alias: String,
predicate: Box<SqlExpr>,
projection: Box<SqlExpr>,
},
JoinAggregate {
outer_focus: Box<SqlExpr>,
outer_alias: String,
inner_field: String,
inner_alias: String,
separator: String,
},
CollectionAgg {
root: String,
path: JsonPath,
},
ScalarFromChain {
chain_sql: String,
projection: Box<SqlExpr>,
offset: i64,
},
}Expand description
Variants§
Lit(LitValue)
Literal scalar.
JsonPath
Navigation through a JSON document.
root is the alias provided by the surrounding plan node — typically
r.data (resource scan), fe.value (lateral unnest), or rec.node
(recursive CTE). path is the chain of steps applied to it.
Fields
Param(usize)
Bound query parameter, 1-based.
Indices 1 and 2 are reserved for tenant_id and resource_type.
Constants from ViewDefinition.constant[] and string literals lifted
out of extension(url) etc. allocate from index 3 upward.
ColRef(String)
Reference to a column projected by a CTE or subquery.
Cast
Type coercion. The dialect lowerer chooses the appropriate cast syntax.
BinOp
Binary operator.
Fields
UnaryOp
Unary operator.
Case
CASE WHEN .. THEN .. ... ELSE .. END.
Fields
Coalesce(Vec<SqlExpr>)
COALESCE(a, b, ...).
NullIf(Box<SqlExpr>, Box<SqlExpr>)
NULLIF(a, b).
AsJson(Box<SqlExpr>)
Wrap a scalar as a JSON value (to_jsonb / json).
JsonAgg(Box<SubQuery>)
Aggregate the rows produced by a subquery into a JSON array
(jsonb_agg / json_group_array). Used for column.collection: true.
Scalar(Box<SubQuery>)
Scalar subquery — the inner plan must project exactly one value per row and return at most one row.
Exists(Box<SubQuery>)
EXISTS(subquery) — collapses to a boolean.
CountSub(Box<SubQuery>)
(SELECT count(*) FROM subquery).
Alias
Names an inner expression for reuse (lowered as a CTE column reference when the same scalar appears in multiple projections).
ReferenceKey
Extracts the id portion of a Reference.reference string. When
expected_type is supplied, returns NULL unless the reference’s type
segment matches (e.g. getReferenceKey(Patient) over Observation/123
returns NULL).
Fields
Boundary
FHIRPath lowBoundary() / highBoundary() — emits a precision-driven
CASE expression over the source’s text form (decimal expands by a
half-step in the last digit; date/dateTime/time pad with the first or
last instant of the largest unspecified unit). The expected
column.type is supplied so the dialect can pick decimal vs.
date/dateTime/time logic.
Fields
side: BoundarySideWhether to take the low or high boundary.
kind: BoundaryKindSource value kind (decimal vs. date/dateTime/time).
WhereExists
FHIRPath <focus>.where(<crit>).exists() — lowers to an EXISTS
subquery that iterates the focus collection (a lateral unnest of a
JSON path) and tests crit against each element. The criterion is
pre-lowered with iter_alias.value set as its path root.
Fields
WhereScalar
FHIRPath <focus>.where(<crit>).<navigation> collapsed to a scalar
subquery: iterate the focus collection, filter by the criterion,
project the navigation off the iteration alias, return at most one
row. Used when a column’s path threads a where() call somewhere in
the middle (e.g. name.where(use='official').family).
Fields
JoinAggregate
FHIRPath <base>.<field>.join(<sep>) — aggregates the values of
<field> across each element of <base> (flattened) into a single
separator-joined string. Lowers to string_agg (PG) /
group_concat (SQLite) over a chained lateral unnest.
Fields
CollectionAgg
column.collection: true projection — aggregates the flattened
values of a JSON path into a JSON array. Each Field step in path
becomes a lateral unnest; the final element values feed into a
json_agg / json_group_array.
Fields
ScalarFromChain
Correlated scalar subquery used for forEach: "<chain>[N]" paths —
FHIRPath indexes the FLATTENED iteration result, but SQLite forbids
correlated subqueries in FROM. Lowering each column to a
scalar-subquery in the SELECT side bypasses that limitation:
(SELECT <projection> FROM <chain_sql> LIMIT 1 OFFSET <offset>).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SqlExpr
impl RefUnwindSafe for SqlExpr
impl Send for SqlExpr
impl Sync for SqlExpr
impl Unpin for SqlExpr
impl UnsafeUnpin for SqlExpr
impl UnwindSafe for SqlExpr
Blanket Implementations§
impl<T> Allocation for T
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.