fraiseql_db/filters/mod.rs
1//! Rich type filter operators and handlers.
2//!
3//! This module provides specialized filter operators for 44 rich scalar types,
4//! enabling powerful queries like:
5//!
6//! - Extract and filter by email domain: `email.domain_eq('example.com')`
7//! - Parse and filter by VIN components: `vin.wmi_eq('1HG')`
8//! - Geographic filtering: `coordinates.distance_within(lat, lng, radius_km)`
9//! - Country lookups: `country.continent_eq('Europe')`
10
11pub mod default_rules;
12pub mod operator_mapping;
13pub mod operators;
14pub mod validators;
15
16pub use default_rules::get_default_rules;
17use fraiseql_error::Result;
18pub use operator_mapping::{OperatorInfo, ParameterType, get_operators_for_type};
19pub use operators::ExtendedOperator;
20use serde_json::Value;
21pub use validators::{ChecksumType, ValidationRule};
22
23/// Handler for extended operator SQL generation.
24///
25/// Each database backend implements this trait to provide database-specific SQL
26/// generation for extended operators.
27pub trait ExtendedOperatorHandler {
28 /// Generate database-specific SQL for an extended operator.
29 ///
30 /// # Errors
31 ///
32 /// Returns `FraiseQLError::Validation` if the operator is not supported
33 /// by this database or parameters are invalid.
34 fn generate_extended_sql(
35 &self,
36 operator: &ExtendedOperator,
37 field_sql: &str,
38 params: &mut Vec<Value>,
39 ) -> Result<String>;
40}
41
42#[cfg(test)]
43mod tests {
44 #[test]
45 fn test_extended_operator_enum_complete() {
46 // Verify all 44 types are represented
47 // This is a compile-time check via pattern matching in sql generators
48 }
49}