pub struct Condition {
pub condition_type: ConditionType,
pub negate: bool,
pub conditions: Vec<ConditionExpression>,
}Expand description
A condition chain for WHERE or HAVING clauses.
§Example
ⓘ
use reinhardt_query::{Cond, Expr};
// All conditions (AND)
let cond = Cond::all()
.add(Expr::col("active").eq(true))
.add(Expr::col("age").gte(18));
// Any condition (OR)
let cond = Cond::any()
.add(Expr::col("role").eq("admin"))
.add(Expr::col("role").eq("moderator"));
// Nested conditions
let cond = Cond::all()
.add(Expr::col("verified").eq(true))
.add(Cond::any()
.add(Expr::col("role").eq("admin"))
.add(Expr::col("role").eq("moderator")));Fields§
§condition_type: ConditionTypeType of condition chain (AND or OR)
negate: boolWhether to negate the entire condition
conditions: Vec<ConditionExpression>The conditions in this chain
Implementations§
Source§impl Condition
impl Condition
Sourcepub fn new(condition_type: ConditionType) -> Self
pub fn new(condition_type: ConditionType) -> Self
Create a new empty condition with the specified type.
Sourcepub fn add<C>(self, condition: C) -> Selfwhere
C: IntoCondition,
pub fn add<C>(self, condition: C) -> Selfwhere
C: IntoCondition,
Add a condition expression.
Sourcepub fn add_option<C>(self, condition: Option<C>) -> Selfwhere
C: IntoCondition,
pub fn add_option<C>(self, condition: Option<C>) -> Selfwhere
C: IntoCondition,
Add a condition only if the option is Some.
Sourcepub fn logical_oper(&self) -> LogicalChainOper
pub fn logical_oper(&self) -> LogicalChainOper
Returns the logical operator for this condition type.
Trait Implementations§
Source§impl IntoCondition for Condition
impl IntoCondition for Condition
Source§fn into_condition_expression(self) -> ConditionExpression
fn into_condition_expression(self) -> ConditionExpression
Convert into a ConditionExpression.
Source§fn into_condition(self) -> Condition
fn into_condition(self) -> Condition
Convert into a Condition (wrapping if necessary).
Auto Trait Implementations§
impl Freeze for Condition
impl !RefUnwindSafe for Condition
impl !Send for Condition
impl !Sync for Condition
impl Unpin for Condition
impl UnsafeUnpin for Condition
impl !UnwindSafe for Condition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more