Skip to main content

Query

Struct Query 

Source
pub struct Query {
    pub from_source: Option<Source>,
    pub select_columns: Vec<String>,
    pub joins: Vec<JoinClause>,
    pub where_clause: Option<String>,
    pub group_by: Vec<String>,
    pub having_clause: Option<String>,
    pub order_by: Vec<String>,
    pub limit: Option<usize>,
    pub offset: Option<usize>,
    pub index_optimizer: Option<IndexOptimizer>,
}
Expand description

Main query builder for Ignis

Fields§

§from_source: Option<Source>§select_columns: Vec<String>§joins: Vec<JoinClause>§where_clause: Option<String>§group_by: Vec<String>§having_clause: Option<String>§order_by: Vec<String>§limit: Option<usize>§offset: Option<usize>§index_optimizer: Option<IndexOptimizer>

Implementations§

Source§

impl Query

Source

pub fn new() -> Self

Create a new query

Source

pub fn from(self, source: Source) -> Self

Set the table to query from

Source

pub fn from_table(self, table: Table) -> Self

Set the table to query from (convenience method)

Source

pub fn from_table_name(self, table_name: impl Into<String>) -> Self

Set the table to query from using table name (convenience method)

Source

pub fn from_view(self, view: View) -> Self

Set the view to query from (convenience method)

Source

pub fn call_procedure(self, procedure: StoredProcedure) -> Self

Call a stored procedure (convenience method)

Source

pub fn call_function(self, function: StoredFunction) -> Self

Call a stored function (convenience method)

Source

pub fn select_columns(self, columns: Vec<String>) -> Self

Add columns to select

Source

pub fn select_columns_str(self, columns: &[&str]) -> Self

Add columns to select (convenience method for &&str)

Source

pub fn filter(self, where_clause: impl Into<String>) -> Self

Set the WHERE clause

Source

pub fn filter_composite_field(self, field_ref: CompositeFieldRef) -> Self

Add composite field filter to WHERE clause

Source

pub fn or_filter_composite_field(self, field_ref: CompositeFieldRef) -> Self

Add composite field filter with OR logic

Source

pub fn order_by(self, column: impl Into<String>) -> Self

Add ORDER BY clause

Source

pub fn order_by_composite_field<T>(self, field: CompositeField<T>) -> Self

Add ORDER BY clause using composite field

Source

pub fn select_composite_field<T>( self, field: CompositeField<T>, alias: Option<String>, ) -> Self

Add composite field to SELECT clause

Source

pub fn limit(self, limit: usize) -> Self

Set the LIMIT

Source

pub fn offset(self, offset: usize) -> Self

Set the OFFSET

Source

pub fn inner_join(self, target: Source, condition: impl Into<String>) -> Self

Add an INNER JOIN

Source

pub fn left_join(self, target: Source, condition: impl Into<String>) -> Self

Add a LEFT JOIN

Source

pub fn right_join(self, target: Source, condition: impl Into<String>) -> Self

Add a RIGHT JOIN

Source

pub fn full_join(self, target: Source, condition: impl Into<String>) -> Self

Add a FULL OUTER JOIN

Source

pub fn inner_join_table( self, table: Table, condition: impl Into<String>, ) -> Self

Add a JOIN using table (convenience method)

Source

pub fn inner_join_table_name( self, table_name: impl Into<String>, condition: impl Into<String>, ) -> Self

Add an INNER JOIN using table name (convenience method)

Source

pub fn left_join_table_name( self, table_name: impl Into<String>, condition: impl Into<String>, ) -> Self

Add a LEFT JOIN using table name (convenience method)

Source

pub fn right_join_table_name( self, table_name: impl Into<String>, condition: impl Into<String>, ) -> Self

Add a RIGHT JOIN using table name (convenience method)

Source

pub fn group_by(self, column: impl Into<String>) -> Self

Add GROUP BY clause

Source

pub fn having(self, condition: impl Into<String>) -> Self

Set HAVING clause

Source

pub fn select(self, expression: impl Into<String>) -> Self

Add a SELECT with aggregation function

Source

pub fn count(self, column: impl Into<String>) -> Self

Add COUNT aggregation

Source

pub fn sum(self, column: impl Into<String>) -> Self

Add SUM aggregation

Source

pub fn avg(self, column: impl Into<String>) -> Self

Add AVG aggregation

Source

pub fn max(self, column: impl Into<String>) -> Self

Add MAX aggregation

Source

pub fn min(self, column: impl Into<String>) -> Self

Add MIN aggregation

Source

pub fn with_indexes(self, indexes: Vec<IndexMeta>) -> Self

Enable index-aware query optimization

Source

pub fn get_index_hints(&self) -> Option<String>

Get index optimization hints for this query

Source

pub fn is_materialized_view(&self) -> bool

Check if this query is against a materialized view

Source

pub fn generate_refresh_sql(&self) -> Option<String>

Generate refresh SQL for materialized views

Source

pub fn is_procedure_call(&self) -> bool

Check if this query is a procedure or function call

Source

pub fn generate_call_sql(&self, parameters: Vec<String>) -> String

Generate CALL statement for procedures or SELECT statement for functions

Source

pub fn to_sql(&self) -> String

Generate the SQL for this query with thread-safe caching for performance

Source

pub fn cache_stats() -> (usize, usize)

Get cache statistics for monitoring

Source

pub fn init_cache()

Initialize the query cache (call once at startup)

Source

pub fn generate_all_sql(&self) -> Vec<String>

Generate all SQL statements for this query (including refresh for materialized views)

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Query

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 Query

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Query

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Hash for Query

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations§

§

impl Freeze for Query

§

impl RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnsafeUnpin for Query

§

impl UnwindSafe for Query

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more