use serde_json::Value;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConditionOperator {
Eq,
Neq,
Gt,
Lt,
In,
Gte,
Lte,
Like,
ILike,
Is,
Contains,
Contained,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Condition {
pub column: String,
pub operator: ConditionOperator,
pub values: Vec<Value>,
pub negated: bool,
pub auto_cast_uuid_value_to_text: bool,
}
impl Condition {
pub fn eq(column: impl Into<String>, value: impl Into<Value>) -> Self {
Self {
column: column.into(),
operator: ConditionOperator::Eq,
values: vec![value.into()],
negated: false,
auto_cast_uuid_value_to_text: true,
}
}
pub fn new(
column: impl Into<String>,
operator: ConditionOperator,
values: Vec<Value>,
negated: bool,
) -> Self {
Self {
column: column.into(),
operator,
values,
negated,
auto_cast_uuid_value_to_text: true,
}
}
pub fn with_uuid_value_text_cast(mut self, enabled: bool) -> Self {
self.auto_cast_uuid_value_to_text = enabled;
self
}
}