pub enum WhereOperator {
Show 39 variants
Eq(Field, Value),
Neq(Field, Value),
Gt(Field, Value),
Gte(Field, Value),
Lt(Field, Value),
Lte(Field, Value),
In(Field, Vec<Value>),
Nin(Field, Vec<Value>),
Contains(Field, String),
ArrayContains(Field, Value),
ArrayContainedBy(Field, Value),
ArrayOverlaps(Field, Vec<Value>),
LenEq(Field, usize),
LenGt(Field, usize),
LenGte(Field, usize),
LenLt(Field, usize),
LenLte(Field, usize),
Icontains(Field, String),
Startswith(Field, String),
Endswith(Field, String),
Like(Field, String),
Ilike(Field, String),
IsNull(Field, bool),
L2Distance {
field: Field,
vector: Vec<f32>,
threshold: f32,
},
CosineDistance {
field: Field,
vector: Vec<f32>,
threshold: f32,
},
InnerProduct {
field: Field,
vector: Vec<f32>,
threshold: f32,
},
JaccardDistance {
field: Field,
set: Vec<String>,
threshold: f32,
},
Matches {
field: Field,
query: String,
language: Option<String>,
},
PlainQuery {
field: Field,
query: String,
},
PhraseQuery {
field: Field,
query: String,
language: Option<String>,
},
WebsearchQuery {
field: Field,
query: String,
language: Option<String>,
},
IsIPv4(Field),
IsIPv6(Field),
IsPrivate(Field),
IsLoopback(Field),
InSubnet {
field: Field,
subnet: String,
},
ContainsSubnet {
field: Field,
subnet: String,
},
ContainsIP {
field: Field,
ip: String,
},
IPRangeOverlap {
field: Field,
range: String,
},
}Expand description
WHERE clause operators
Supports type-safe, audit-friendly WHERE clause construction without raw SQL strings.
§Categories
- Comparison: Eq, Neq, Gt, Gte, Lt, Lte
- Array: In, Nin, Contains, ArrayContains, ArrayContainedBy, ArrayOverlaps
- Array Length: LenEq, LenGt, LenGte, LenLt, LenLte
- String: Icontains, Startswith, Endswith, Like, Ilike
- Null: IsNull
- Vector Distance: L2Distance, CosineDistance, InnerProduct, JaccardDistance
- Full-Text Search: Matches, PlainQuery, PhraseQuery, WebsearchQuery
- Network: IsIPv4, IsIPv6, IsPrivate, IsLoopback, InSubnet, ContainsSubnet, ContainsIP, IPRangeOverlap
Variants§
Eq(Field, Value)
Equal: field = value
Neq(Field, Value)
Not equal: field != value or field <> value
Gt(Field, Value)
Greater than: field > value
Gte(Field, Value)
Greater than or equal: field >= value
Lt(Field, Value)
Less than: field < value
Lte(Field, Value)
Less than or equal: field <= value
In(Field, Vec<Value>)
Array contains value: field IN (...)
Nin(Field, Vec<Value>)
Array does not contain value: field NOT IN (...)
Contains(Field, String)
String contains substring: field LIKE '%substring%'
ArrayContains(Field, Value)
Array contains element: PostgreSQL array operator @>
Generated SQL: field @> array[value]
ArrayContainedBy(Field, Value)
Array is contained by: PostgreSQL array operator <@
Generated SQL: field <@ array[value]
ArrayOverlaps(Field, Vec<Value>)
Arrays overlap: PostgreSQL array operator &&
Generated SQL: field && array[value]
LenEq(Field, usize)
Array length equals: array_length(field, 1) = value
LenGt(Field, usize)
Array length greater than: array_length(field, 1) > value
LenGte(Field, usize)
Array length greater than or equal: array_length(field, 1) >= value
LenLt(Field, usize)
Array length less than: array_length(field, 1) < value
LenLte(Field, usize)
Array length less than or equal: array_length(field, 1) <= value
Icontains(Field, String)
Case-insensitive contains: field ILIKE '%substring%'
Startswith(Field, String)
Starts with: field LIKE 'prefix%'
Endswith(Field, String)
Ends with: field LIKE '%suffix'
Like(Field, String)
LIKE pattern matching: field LIKE pattern
Ilike(Field, String)
Case-insensitive LIKE: field ILIKE pattern
IsNull(Field, bool)
IS NULL: field IS NULL or field IS NOT NULL
When the boolean is true, generates IS NULL
When false, generates IS NOT NULL
L2Distance
L2 (Euclidean) distance: l2_distance(field, vector) < threshold
Requires pgvector extension.
Fields
CosineDistance
Cosine distance: cosine_distance(field, vector) < threshold
Requires pgvector extension.
Fields
InnerProduct
Inner product: inner_product(field, vector) > threshold
Requires pgvector extension.
Fields
JaccardDistance
Jaccard distance: jaccard_distance(field, set) < threshold
Works with text arrays, measures set overlap.
Fields
Matches
Full-text search with language: field @@ plainto_tsquery(language, query)
If language is None, defaults to ‘english’
Fields
PlainQuery
Plain text query: field @@ plainto_tsquery(query)
Uses no language specification
PhraseQuery
Phrase query with language: field @@ phraseto_tsquery(language, query)
If language is None, defaults to ‘english’
Fields
WebsearchQuery
Web search query with language: field @@ websearch_to_tsquery(language, query)
If language is None, defaults to ‘english’
Fields
IsIPv4(Field)
Check if IP is IPv4: family(field) = 4
IsIPv6(Field)
Check if IP is IPv6: family(field) = 6
IsPrivate(Field)
Check if IP is private (RFC1918): matches private ranges
IsLoopback(Field)
Check if IP is loopback: IPv4 127.0.0.0/8 or IPv6 ::1/128
InSubnet
IP is in subnet: field << subnet
The subnet should be in CIDR notation (e.g., “192.168.0.0/24”)
ContainsSubnet
Network contains subnet: field >> subnet
The subnet should be in CIDR notation
Fields
ContainsIP
Network/range contains IP: field >> ip
The IP should be a single address (e.g., “192.168.1.1”)
IPRangeOverlap
IP ranges overlap: field && range
The range should be in CIDR notation
Implementations§
Trait Implementations§
Source§impl Clone for WhereOperator
impl Clone for WhereOperator
Source§fn clone(&self) -> WhereOperator
fn clone(&self) -> WhereOperator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more