Module filter

Module filter 

Source
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§

AndFilterBuilder
Builder for constructing AND filters with pre-allocated capacity.
FluentFilterBuilder
A fluent builder for constructing filters with a convenient API.
OrFilterBuilder
Builder for constructing OR filters with pre-allocated capacity.

Enums§

Filter
A complete filter that can be converted to SQL.
FilterValue
A filter value that can be used in comparisons.
ScalarFilter
Scalar filter operations.

Type Aliases§

FieldName
A field name that can be either a static string (zero allocation) or an owned string.
LargeValueList
Large value list type with 32 elements inline. Use this for known large IN clauses (e.g., batch operations).
SmallValueList
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).
ValueList
A list of filter values for IN/NOT IN clauses.