fraiseql_wire/operators/mod.rs
1//! Operator-based SQL generation system
2//!
3//! This module provides type-safe operator abstractions for building WHERE clauses,
4//! ORDER BY clauses, and query modifiers (LIMIT/OFFSET) without raw SQL strings.
5//!
6//! # Design Philosophy
7//!
8//! fraiseql-wire maintains backward compatibility with the existing string-based API
9//! while offering operator abstractions for type safety and auditability:
10//!
11//! ```text
12//! // Requires: live Postgres connection via FraiseClient.
13//! // Old style (still works)
14//! client.query("users")
15//! .where_sql("data->>'name' = 'John'")
16//! .execute()
17//! .await?;
18//!
19//! // New style (type-safe)
20//! client.query("users")
21//! .where_operator(WhereOperator::Eq(
22//! Field::JsonbField("name".to_string()),
23//! Value::String("John".to_string()),
24//! ))
25//! .execute()
26//! .await?;
27//! ```
28//!
29//! # Operator Coverage
30//!
31//! - **Comparison**: Eq, Neq, Gt, Gte, Lt, Lte
32//! - **Array**: In, Nin, Contains, `ArrayContains`, `ArrayContainedBy`, `ArrayOverlaps`
33//! - **Array Length**: `LenEq`, `LenGt`, `LenGte`, `LenLt`, `LenLte`
34//! - **String**: Contains, Icontains, Startswith, Endswith, Like, Ilike
35//! - **Null**: `IsNull`
36//! - **Vector Distance**: `L2Distance`, `CosineDistance`, `InnerProduct`, `JaccardDistance`
37//! - **Full-Text Search**: Matches, `PlainQuery`, `PhraseQuery`, `WebsearchQuery`
38//! - **Network**: `IsIPv4`, `IsIPv6`, `IsPrivate`, `IsLoopback`, `InSubnet`, `ContainsSubnet`, `ContainsIP`, `IPRangeOverlap`
39
40pub mod field;
41pub mod order_by;
42pub mod sql_gen;
43pub mod where_operator;
44
45pub use field::{Field, Value};
46pub use order_by::{Collation, FieldSource, NullsHandling, OrderByClause, SortOrder};
47pub use sql_gen::generate_where_operator_sql;
48pub use where_operator::WhereOperator;