pub struct QueryState {Show 20 fields
pub from: String,
pub filters: Vec<FilterCondition>,
pub joins: Vec<JoinSpec>,
pub group_bys: Vec<String>,
pub havings: Vec<HavingExpr>,
pub orderings: Vec<OrderBy>,
pub offset: Option<usize>,
pub limit: Option<usize>,
pub includes: Vec<IncludePath>,
pub projected_columns: Option<Vec<String>>,
pub is_count: bool,
pub is_exists: bool,
pub aggregate: Option<String>,
pub aggregate_column: Option<String>,
pub parameters: Vec<DbValue>,
pub where_expr: Option<BoolExpr>,
pub distinct: bool,
pub windows: Vec<WindowSpec>,
pub ctes: Vec<CteSpec>,
pub set_operations: Vec<SetOpSpec>,
}Expand description
Accumulated intent for a single query.
Fields§
§from: StringFROM table / subquery segment.
filters: Vec<FilterCondition>WHERE clause conditions.
joins: Vec<JoinSpec>JOIN specifications.
group_bys: Vec<String>GROUP BY columns.
havings: Vec<HavingExpr>HAVING conditions stored as AST nodes so they can be compiled with the
provider-specific placeholder syntax (? vs $N) at SQL generation
time, rather than being pre-compiled to a fixed placeholder.
orderings: Vec<OrderBy>ORDER BY clauses.
offset: Option<usize>OFFSET (Skip).
limit: Option<usize>LIMIT (Take).
includes: Vec<IncludePath>Include navigation paths.
projected_columns: Option<Vec<String>>Whether this is a projection (SELECT col1, col2 instead of SELECT *).
is_count: boolWhether this is a COUNT query.
is_exists: boolWhether this is an EXISTS sub-query.
aggregate: Option<String>Aggregate function to apply: “SUM”, “AVG”, “MIN”, “MAX”, “COUNT”
aggregate_column: Option<String>The column to aggregate.
parameters: Vec<DbValue>Collected parameter values in order of appearance.
where_expr: Option<BoolExpr>Boolean WHERE expression (preferred over filters).
distinct: boolWhether to emit SELECT DISTINCT.
windows: Vec<WindowSpec>Window function projections (v1.1). Emitted in the SELECT list as
func(col) OVER (PARTITION BY ... ORDER BY ...) AS alias.
ctes: Vec<CteSpec>CTE definitions (v1.1). Emitted as WITH name AS (...) prefix
before the SELECT. CTE parameters are prepended to the query’s
parameter list at execution time.
set_operations: Vec<SetOpSpec>Set operations (UNION / INTERSECT / EXCEPT) appended after the main SELECT. Multiple operations chain left-to-right.
Implementations§
Source§impl QueryState
impl QueryState
pub fn new(from: impl Into<String>) -> Self
Sourcepub fn to_sql_with(&self, gen: &dyn ISqlGenerator) -> String
pub fn to_sql_with(&self, gen: &dyn ISqlGenerator) -> String
Compile the state into a SQL string using the provider’s placeholder style.
Sourcepub fn all_params(&self) -> Vec<DbValue>
pub fn all_params(&self) -> Vec<DbValue>
Returns all parameter values for execution: CTE parameters first (in declaration order), followed by WHERE/HAVING parameters, then set operation operand params.
This ordering matches the placeholder order in the generated SQL, where CTE bodies appear before the main SELECT and set operations appear after.
Trait Implementations§
Source§impl Clone for QueryState
impl Clone for QueryState
Source§fn clone(&self) -> QueryState
fn clone(&self) -> QueryState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more