pub enum HavingExpr {
Compare {
agg: AggKind,
col: String,
op: CompareOp,
value: DbValue,
},
And(Box<HavingExpr>, Box<HavingExpr>),
Or(Box<HavingExpr>, Box<HavingExpr>),
Not(Box<HavingExpr>),
CompareAgg {
left_agg: AggKind,
left_col: String,
op: CompareOp,
right_agg: AggKind,
right_col: String,
},
}Expand description
AST node for HAVING expressions.
Supports boolean combinations (AND/OR/NOT) and aggregate-versus-aggregate
comparisons in addition to the basic agg(col) op value form. Generated by
linq!(having ...) (Form B) expansion and compiled to SQL by to_sql.
Variants§
Compare
agg(col) op value — basic comparison against a literal.
And(Box<HavingExpr>, Box<HavingExpr>)
expr AND expr.
Or(Box<HavingExpr>, Box<HavingExpr>)
expr OR expr.
Not(Box<HavingExpr>)
NOT expr.
CompareAgg
agg(col1) op agg(col2) — aggregate-vs-aggregate comparison (no bound parameter).
Implementations§
Source§impl HavingExpr
impl HavingExpr
Sourcepub fn to_sql(&self, gen: &dyn ISqlGenerator, param_idx: &mut usize) -> String
pub fn to_sql(&self, gen: &dyn ISqlGenerator, param_idx: &mut usize) -> String
Recursively compiles the expression into a SQL fragment using the
provider-specific placeholder syntax (? for SQLite/MySQL, $N for
PostgreSQL).
param_idx is advanced past each bound parameter in left-to-right
order, matching the order produced by HavingExpr::collect_params.
This ensures PostgreSQL’s 1-indexed $N placeholders stay contiguous
with the WHERE clause’s placeholders.
Sourcepub fn collect_params(&self) -> Vec<DbValue>
pub fn collect_params(&self) -> Vec<DbValue>
Collects bound parameter values in the same left-to-right order that
HavingExpr::to_sql emits placeholders. Used to populate the query
parameter vector at registration time so that compile_sql returns
params matching the placeholder order.
Trait Implementations§
Source§impl Clone for HavingExpr
impl Clone for HavingExpr
Source§fn clone(&self) -> HavingExpr
fn clone(&self) -> HavingExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more