pub struct SqlCondition<P> { /* private fields */ }Expand description
A rendered SQL-style condition together with its positional bind parameters.
Shared by the SQL-flavoured vector stores, whose filter algebra differs only
in the parameter type P and in the placeholder token their driver expects
($ for Postgres, ? for CQL). The placeholder is therefore supplied by the
caller on every leaf constructor rather than baked into this type.
Parameters are collected left to right in the order their placeholders appear
in SqlCondition::condition, which is the order drivers bind them in.
Implementations§
Source§impl<P> SqlCondition<P>
impl<P> SqlCondition<P>
Sourcepub fn binary(
key: impl AsRef<str>,
op: &str,
placeholder: &str,
value: P,
) -> SqlCondition<P>
pub fn binary( key: impl AsRef<str>, op: &str, placeholder: &str, value: P, ) -> SqlCondition<P>
Renders <key> <op> <placeholder> bound to a single parameter, e.g.
price >= $.
Sourcepub fn list(
key: impl AsRef<str>,
op: &str,
placeholder: &str,
values: Vec<P>,
) -> SqlCondition<P>
pub fn list( key: impl AsRef<str>, op: &str, placeholder: &str, values: Vec<P>, ) -> SqlCondition<P>
Renders <key> <op> (<placeholder>, ...) with one placeholder per value,
e.g. id IN (?, ?).
Sourcepub fn raw(condition: impl Into<String>) -> SqlCondition<P>
pub fn raw(condition: impl Into<String>) -> SqlCondition<P>
Wraps an already-rendered, parameterless condition such as id is null.
Sourcepub fn and(self, rhs: SqlCondition<P>) -> SqlCondition<P>
pub fn and(self, rhs: SqlCondition<P>) -> SqlCondition<P>
Conjoins two conditions as (lhs) AND (rhs), concatenating their parameters.
Sourcepub fn or(self, rhs: SqlCondition<P>) -> SqlCondition<P>
pub fn or(self, rhs: SqlCondition<P>) -> SqlCondition<P>
Disjoins two conditions as (lhs) OR (rhs), concatenating their parameters.
Sourcepub fn not(self) -> SqlCondition<P>
pub fn not(self) -> SqlCondition<P>
Negates the condition as NOT (condition), keeping its parameters.
Sourcepub fn condition(&self) -> &str
pub fn condition(&self) -> &str
The rendered condition, with placeholders as the caller supplied them.
Sourcepub fn into_parts(self) -> (String, Vec<P>)
pub fn into_parts(self) -> (String, Vec<P>)
Consumes the condition, returning the rendered text and its parameters.
Trait Implementations§
Source§impl<P> Clone for SqlCondition<P>where
P: Clone,
impl<P> Clone for SqlCondition<P>where
P: Clone,
Source§fn clone(&self) -> SqlCondition<P>
fn clone(&self) -> SqlCondition<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P> Debug for SqlCondition<P>where
P: Debug,
impl<P> Debug for SqlCondition<P>where
P: Debug,
Source§impl<P> Default for SqlCondition<P>
Hand-written so that P needs no Default of its own: a parameterless
empty condition is meaningful for every parameter type.
impl<P> Default for SqlCondition<P>
Hand-written so that P needs no Default of its own: a parameterless
empty condition is meaningful for every parameter type.