toasty_core/stmt/expr_intersects.rs
1use super::Expr;
2
3/// Boolean: `lhs` and `rhs` (both arrays) share at least one element.
4///
5/// PostgreSQL: `lhs && rhs`. Drives [`Path::intersects`](super::Path).
6#[derive(Debug, Clone, PartialEq)]
7pub struct ExprIntersects {
8 /// The first array operand.
9 pub lhs: Box<Expr>,
10 /// The second array operand.
11 pub rhs: Box<Expr>,
12}
13
14impl Expr {
15 /// Build an `Intersects` array predicate (`lhs && rhs` on PostgreSQL).
16 pub fn array_intersects(lhs: impl Into<Self>, rhs: impl Into<Self>) -> Self {
17 ExprIntersects {
18 lhs: Box::new(lhs.into()),
19 rhs: Box::new(rhs.into()),
20 }
21 .into()
22 }
23}
24
25impl From<ExprIntersects> for Expr {
26 fn from(value: ExprIntersects) -> Self {
27 Self::Intersects(value)
28 }
29}