Skip to main content

QueryState

Struct QueryState 

Source
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: String

FROM 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: bool

Whether this is a COUNT query.

§is_exists: bool

Whether 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: bool

Whether 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

Source

pub fn new(from: impl Into<String>) -> Self

Source

pub fn to_sql_with(&self, gen: &dyn ISqlGenerator) -> String

Compile the state into a SQL string using the provider’s placeholder style.

Source

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.

Source

pub fn to_sql(&self) -> String

Compile SQL with ? placeholders (SQLite/MySQL style).

Source

pub fn params(&self) -> &[DbValue]

Returns the accumulated parameters.

Trait Implementations§

Source§

impl Clone for QueryState

Source§

fn clone(&self) -> QueryState

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 QueryState

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> 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, 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.