Expand description
Filter types for building WHERE clauses.
This module provides the building blocks for constructing type-safe query filters.
§Performance
Field names use Cow<'static, str> for optimal performance:
- Static strings (
&'static str) are borrowed with zero allocation - Dynamic strings are stored as owned
String - Use
.into()from static strings for best performance
§Examples
§Basic Filters
use prax_query::filter::{Filter, FilterValue};
// Equality filter - zero allocation with static str
let filter = Filter::Equals("id".into(), FilterValue::Int(42));
// String contains
let filter = Filter::Contains("email".into(), FilterValue::String("@example.com".into()));
// Greater than
let filter = Filter::Gt("age".into(), FilterValue::Int(18));§Combining Filters
use prax_query::filter::{Filter, FilterValue};
// AND combination - use Filter::and() for convenience
let filter = Filter::and([
Filter::Equals("active".into(), FilterValue::Bool(true)),
Filter::Gt("score".into(), FilterValue::Int(100)),
]);
// OR combination - use Filter::or() for convenience
let filter = Filter::or([
Filter::Equals("status".into(), FilterValue::String("pending".into())),
Filter::Equals("status".into(), FilterValue::String("processing".into())),
]);
// NOT
let filter = Filter::Not(Box::new(
Filter::Equals("deleted".into(), FilterValue::Bool(true))
));§Null Checks
use prax_query::filter::{Filter, FilterValue};
// Is null
let filter = Filter::IsNull("deleted_at".into());
// Is not null
let filter = Filter::IsNotNull("verified_at".into());Structs§
- AndFilter
Builder - Builder for constructing AND filters with pre-allocated capacity.
- Fluent
Filter Builder - A fluent builder for constructing filters with a convenient API.
- OrFilter
Builder - Builder for constructing OR filters with pre-allocated capacity.
Enums§
- Filter
- A complete filter that can be converted to SQL.
- Filter
Value - A filter value that can be used in comparisons.
- Scalar
Filter - Scalar filter operations.
Type Aliases§
- Field
Name - A field name that can be either a static string (zero allocation) or an owned string.
- Large
Value List - Large value list type with 32 elements inline. Use this for known large IN clauses (e.g., batch operations).
- Small
Value List - SmallVec-based value list for hot paths where small IN clauses are common. Use this explicitly when you know IN clauses are small (≤8 elements).
- Value
List - A list of filter values for IN/NOT IN clauses.