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,
) -> Self
pub fn binary( key: impl AsRef<str>, op: &str, placeholder: &str, value: P, ) -> Self
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>,
) -> Self
pub fn list( key: impl AsRef<str>, op: &str, placeholder: &str, values: Vec<P>, ) -> Self
Renders <key> <op> (<placeholder>, ...) with one placeholder per value,
e.g. id IN (?, ?).
Sourcepub fn raw(condition: impl Into<String>) -> Self
pub fn raw(condition: impl Into<String>) -> Self
Wraps an already-rendered, parameterless condition such as id is null.
Sourcepub fn and(self, rhs: Self) -> Self
pub fn and(self, rhs: Self) -> Self
Conjoins two conditions as (lhs) AND (rhs), concatenating their parameters.
Sourcepub fn or(self, rhs: Self) -> Self
pub fn or(self, rhs: Self) -> Self
Disjoins two conditions as (lhs) OR (rhs), concatenating their 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> Clone for SqlCondition<P>
impl<P: Clone> Clone for SqlCondition<P>
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> Debug for SqlCondition<P>
impl<P: Debug> Debug for SqlCondition<P>
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.
Source§impl<'de, P> Deserialize<'de> for SqlCondition<P>where
P: Deserialize<'de>,
impl<'de, P> Deserialize<'de> for SqlCondition<P>where
P: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl<P> Freeze for SqlCondition<P>
impl<P> RefUnwindSafe for SqlCondition<P>where
P: RefUnwindSafe,
impl<P> Send for SqlCondition<P>where
P: Send,
impl<P> Sync for SqlCondition<P>where
P: Sync,
impl<P> Unpin for SqlCondition<P>where
P: Unpin,
impl<P> UnsafeUnpin for SqlCondition<P>
impl<P> UnwindSafe for SqlCondition<P>where
P: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> 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