Skip to main content

QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder;
Expand description

Query builder for converting plans to SQL.

Implementations§

Source§

impl QueryBuilder

Source

pub fn build_read(tree: &ReadPlanTree) -> Result<SqlFragment>

Build a SELECT query from a read plan tree.

Source

pub fn column_sql(field: &CoercibleField) -> String

A column reference with its JSON path, as it appears in SQL.

Exposed for ordering by an embedded resource’s column, which is assembled outside the read plan.

Source

pub fn qualified_column_sql( qualifier: Option<&str>, field: &CoercibleField, ) -> String

The same, with the column qualified by a relation alias.

The alias belongs to the column, not to the expression around it: to_jsonb(e2."settings")->'a', never e2.to_jsonb(...), which reads as a function in a schema called e2.

Source

pub fn filter_sql(filter: &Filter, pg_type: &str) -> Result<SqlFragment>

Build the SQL for a single filter against a column of pg_type.

Exposed for the embedding path, which applies filters inside a child subquery it assembles itself rather than through a full plan. Column names are left unqualified: inside the child’s subselect the innermost FROM wins, so a bare name binds to the child. The caller is responsible for having checked the column exists there – otherwise the name would resolve outward to the correlated parent instead.

Source

pub fn logic_sql<F>(tree: &LogicTree, type_resolver: F) -> Result<SqlFragment>
where F: Fn(&str) -> String + Copy,

Build the SQL for a logic tree against a table whose column types type_resolver supplies.

Exposed for the same reason as filter_sql: an embedded resource’s and=/or= is applied inside a subquery the embedding path assembles itself, without going through a full plan.

Source

pub fn build_mutate(plan: &MutatePlan) -> Result<SqlFragment>

Build a mutation query.

Source

pub fn build_call( plan: &CallPlan, read: Option<&ReadPlanTree>, ) -> Result<SqlFragment>

Build an RPC call query.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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