pub enum Predicate {
Comparison {
left: Expression,
op: ComparisonOperator,
right: Expression,
},
And {
left: Box<Predicate>,
right: Box<Predicate>,
},
Or {
left: Box<Predicate>,
right: Box<Predicate>,
},
Not {
child: Box<Predicate>,
},
Between {
expr: Expression,
low: Expression,
high: Expression,
},
In {
expr: Expression,
target: InTarget,
},
Like {
expr: Expression,
pattern: String,
},
IsNull {
expr: Expression,
},
Exists {
query: Box<QueryPlan>,
},
}Expand description
A boolean condition used by WHERE, HAVING, and join clauses.
Like Expression, this is serialized with an internal type
tag. The In and Between variants are the only way to express
list membership and range checks; the bare comparison operators
of the same name are reserved for the dedicated predicate shapes.
§Examples
use vlorql_core::schema::{Predicate, Expression, ComparisonOperator, DataType};
let pred = Predicate::Comparison {
left: Expression::ColumnRef {
table: Some("users".to_owned()),
column: "age".to_owned(),
},
op: ComparisonOperator::Gte,
right: Expression::Literal {
value: serde_json::json!(18),
data_type: DataType::Int,
},
};
assert!(matches!(pred, Predicate::Comparison { .. }));Variants§
Comparison
A comparison between two expressions.
Fields
left: ExpressionLeft-hand operand.
op: ComparisonOperatorThe comparison operator.
right: ExpressionRight-hand operand.
And
The conjunction of two predicates.
Or
The disjunction of two predicates.
Not
The negation of a predicate.
Between
A value constrained to an inclusive range.
Fields
expr: ExpressionThe value being tested.
low: ExpressionInclusive lower bound.
high: ExpressionInclusive upper bound.
In
A value constrained to a list of expressions or a subquery.
Like
A string pattern match.
Fields
expr: ExpressionThe value being tested.
IsNull
A null check.
Fields
expr: ExpressionThe value being tested.
Exists
Tests whether a subquery returns any rows.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Predicate
impl<'de> Deserialize<'de> for Predicate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Predicate
impl JsonSchema for Predicate
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Predicate
Auto Trait Implementations§
impl Freeze for Predicate
impl RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnsafeUnpin for Predicate
impl UnwindSafe for Predicate
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request