pub struct QueryBuilder;Expand description
Query builder for converting plans to SQL.
Implementations§
Source§impl QueryBuilder
impl QueryBuilder
Sourcepub fn build_read(tree: &ReadPlanTree) -> Result<SqlFragment>
pub fn build_read(tree: &ReadPlanTree) -> Result<SqlFragment>
Build a SELECT query from a read plan tree.
Sourcepub fn column_sql(field: &CoercibleField) -> String
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.
Sourcepub fn qualified_column_sql(
qualifier: Option<&str>,
field: &CoercibleField,
) -> String
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.
Sourcepub fn filter_sql(filter: &Filter, pg_type: &str) -> Result<SqlFragment>
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.
Sourcepub fn logic_sql<F>(tree: &LogicTree, type_resolver: F) -> Result<SqlFragment>
pub fn logic_sql<F>(tree: &LogicTree, type_resolver: F) -> Result<SqlFragment>
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.
Sourcepub fn build_mutate(plan: &MutatePlan) -> Result<SqlFragment>
pub fn build_mutate(plan: &MutatePlan) -> Result<SqlFragment>
Build a mutation query.
Sourcepub fn build_call(
plan: &CallPlan,
read: Option<&ReadPlanTree>,
) -> Result<SqlFragment>
pub fn build_call( plan: &CallPlan, read: Option<&ReadPlanTree>, ) -> Result<SqlFragment>
Build an RPC call query.
Auto Trait Implementations§
impl Freeze for QueryBuilder
impl RefUnwindSafe for QueryBuilder
impl Send for QueryBuilder
impl Sync for QueryBuilder
impl Unpin for QueryBuilder
impl UnsafeUnpin for QueryBuilder
impl UnwindSafe for QueryBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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