pub struct FilterCondition {
pub field: String,
pub operator: FilterOperator,
pub value: FilterValue,
pub logical: FilterLogical,
pub column_type: Option<String>,
}Expand description
A single filter condition
Fields§
§field: String§operator: FilterOperator§value: FilterValue§logical: FilterLogical§column_type: Option<String>Implementations§
Source§impl FilterCondition
impl FilterCondition
Sourcepub fn new(field: String, operator: FilterOperator, value: FilterValue) -> Self
pub fn new(field: String, operator: FilterOperator, value: FilterValue) -> Self
Create a new filter condition
Sourcepub fn needs_value_cast(&self) -> bool
pub fn needs_value_cast(&self) -> bool
True when this condition binds a value it compares with =, <, IN, BETWEEN and the
like, yet carries no cast for it. Such a value is bound as text, and PostgreSQL has no
implicit comparison between text and a boolean, number, uuid, date or timestamp column, so
the caller must find the column’s type before the query can run. Pattern operators (LIKE,
contain, …) and null checks are text matches or bind nothing, so they never need one.
Sourcepub fn needs_type_qualification(&self) -> bool
pub fn needs_type_qualification(&self) -> bool
Whether this condition’s cast names a user-defined type without its schema (an enum such
as task_status from a generated hint). Such a name only resolves when the type’s schema
is on the search path, which a tenant database need not have; the caller qualifies it from
the catalog before the query runs.
Sourcepub fn with_logical(self, logical: FilterLogical) -> Self
pub fn with_logical(self, logical: FilterLogical) -> Self
Set the logical operator
Sourcepub fn with_column_type(self, column_type: String) -> Self
pub fn with_column_type(self, column_type: String) -> Self
Set the column type for casting (e.g., “user_status”)
Sourcepub fn build_sql(&self, param_idx: &mut usize) -> String
pub fn build_sql(&self, param_idx: &mut usize) -> String
Build SQL WHERE clause for this condition (with logical prefix)
Sourcepub fn get_params(&self) -> Vec<String>
pub fn get_params(&self) -> Vec<String>
Get the parameter values for binding
Trait Implementations§
Source§impl Clone for FilterCondition
impl Clone for FilterCondition
Auto Trait Implementations§
impl Freeze for FilterCondition
impl RefUnwindSafe for FilterCondition
impl Send for FilterCondition
impl Sync for FilterCondition
impl Unpin for FilterCondition
impl UnsafeUnpin for FilterCondition
impl UnwindSafe for FilterCondition
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,
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