pub enum QueryFilterOperator {
Equal,
NotEqual,
GreaterThan,
GreaterOrEqual,
LessThan,
LessOrEqual,
In,
NotIn,
IsNull,
IsNotNull,
Like,
NotLike,
}Expand description
Represents SQL comparison operators for filtering.
These operators provide type-safe filtering capabilities beyond simple equality. All operators are validated and protected against SQL injection.
§Security
- All operators use parameterized queries
- Column names are validated against the model struct
- Input values are bound as parameters, never concatenated
§Examples
use sqlx_paginated::{QueryFilterOperator, QueryParamsBuilder};
use serde::Serialize;
#[derive(Serialize, Default)]
struct Product {
price: f64,
stock: i32,
status: String,
}
let params = QueryParamsBuilder::<Product>::new()
.with_filter_operator("price", QueryFilterOperator::GreaterThan, "10.00")
.with_filter_operator("stock", QueryFilterOperator::LessOrEqual, "100")
.with_filter_operator("status", QueryFilterOperator::NotEqual, "deleted")
.build();Variants§
Equal
Equal to (=)
Example: age = 25
NotEqual
Not equal to (!= or <>)
Example: status != 'deleted'
GreaterThan
Greater than (>)
Example: price > 10.00
GreaterOrEqual
Greater than or equal to (>=)
Example: age >= 18
LessThan
Less than (<)
Example: stock < 10
LessOrEqual
Less than or equal to (<=)
Example: price <= 100.00
In
IN clause - value in a list
Values should be comma-separated strings.
Example: status IN ('active', 'pending')
NotIn
NOT IN clause - value not in a list
Values should be comma-separated strings.
Example: role NOT IN ('admin', 'moderator')
IsNull
IS NULL check
Example: deleted_at IS NULL
IsNotNull
IS NOT NULL check
Example: email IS NOT NULL
Like
LIKE pattern matching (case-insensitive)
Supports SQL wildcards: % (any characters) and _ (single character)
Example: email LIKE '%@company.com'
NotLike
NOT LIKE pattern matching (case-insensitive)
Example: email NOT LIKE '%@spam.com'
Implementations§
Source§impl QueryFilterOperator
impl QueryFilterOperator
Sourcepub fn requires_value(&self) -> bool
pub fn requires_value(&self) -> bool
Returns true if the operator requires a value (excludes IS NULL/IS NOT NULL).
Sourcepub fn accepts_multiple_values(&self) -> bool
pub fn accepts_multiple_values(&self) -> bool
Returns true if the operator accepts multiple values (IN/NOT IN).
Trait Implementations§
Source§impl Clone for QueryFilterOperator
impl Clone for QueryFilterOperator
Source§fn clone(&self) -> QueryFilterOperator
fn clone(&self) -> QueryFilterOperator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QueryFilterOperator
impl Debug for QueryFilterOperator
Source§impl Default for QueryFilterOperator
impl Default for QueryFilterOperator
Source§fn default() -> QueryFilterOperator
fn default() -> QueryFilterOperator
Source§impl<'de> Deserialize<'de> for QueryFilterOperator
impl<'de> Deserialize<'de> for QueryFilterOperator
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>,
Source§impl PartialEq for QueryFilterOperator
impl PartialEq for QueryFilterOperator
Source§impl Serialize for QueryFilterOperator
impl Serialize for QueryFilterOperator
impl StructuralPartialEq for QueryFilterOperator
Auto Trait Implementations§
impl Freeze for QueryFilterOperator
impl RefUnwindSafe for QueryFilterOperator
impl Send for QueryFilterOperator
impl Sync for QueryFilterOperator
impl Unpin for QueryFilterOperator
impl UnwindSafe for QueryFilterOperator
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> 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