pub enum Predicate {
Comparison {
left: Box<Expression>,
op: ComparisonOperator,
right: Box<Expression>,
},
And {
left: Box<Predicate>,
right: Box<Predicate>,
},
Or {
left: Box<Predicate>,
right: Box<Predicate>,
},
Not {
child: Box<Predicate>,
},
Between {
expr: Box<Expression>,
low: Box<Expression>,
high: Box<Expression>,
},
In {
expr: Box<Expression>,
target: InTarget,
},
Like {
expr: Box<Expression>,
pattern: String,
},
IsNull {
expr: Box<Expression>,
},
Exists {
query: Box<QueryPlan>,
},
True,
False,
}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: Box::new(Expression::ColumnRef {
table: Some("users".to_owned()),
column: "age".to_owned(),
}),
op: ComparisonOperator::Gte,
right: Box::new(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: Box<Expression>Left-hand operand.
op: ComparisonOperatorThe comparison operator.
right: Box<Expression>Right-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: Box<Expression>The value being tested.
low: Box<Expression>Inclusive lower bound.
high: Box<Expression>Inclusive upper bound.
In
A value constrained to a list of expressions or a subquery.
Like
A string pattern match.
Fields
expr: Box<Expression>The value being tested.
IsNull
A null check.
Fields
expr: Box<Expression>The value being tested.
Exists
Tests whether a subquery returns any rows.
True
A constant true value (used internally by the optimizer).
False
A constant false value (used internally by the optimizer).
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 Forget for Predicate
impl Freeze for Predicatewhere
*const Expression is !null: Freeze,
PhantomData<Expression>: Freeze,
*const Predicate is !null: Freeze,
PhantomData<Predicate>: Freeze,
*const u8 is !null: Freeze,
*const QueryPlan is !null: Freeze,
PhantomData<QueryPlan>: Freeze,
PhantomData<u8>: Freeze,
impl Move for Predicate
impl RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnsafeUnpin for Predicatewhere
*const Expression is !null: UnsafeUnpin,
PhantomData<Expression>: UnsafeUnpin,
*const Predicate is !null: UnsafeUnpin,
PhantomData<Predicate>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
*const QueryPlan is !null: UnsafeUnpin,
PhantomData<QueryPlan>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for Predicatewhere
BoxRaw<Expression>: UnwindSafe,
BoxRaw<Predicate>: UnwindSafe,
RawVecInner: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BoxRaw<Vec<Expression>>: UnwindSafe,
BoxRaw<QueryPlan>: UnwindSafe,
BoxRaw<Vec<WhenThen>>: UnwindSafe,
BoxRaw<WindowSpec>: UnwindSafe,
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