Skip to main content

ArrayExprExt

Trait ArrayExprExt 

Source
pub trait ArrayExprExt<'a>: Expr<'a, PostgresValue<'a>> + Sized {
    // Provided methods
    fn array_contains<R>(
        self,
        other: R,
    ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
       where R: Expr<'a, PostgresValue<'a>>,
             Self::SQLType: ArrayOperand<R::SQLType> { ... }
    fn array_contained<R>(
        self,
        other: R,
    ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
       where R: Expr<'a, PostgresValue<'a>>,
             Self::SQLType: ArrayOperand<R::SQLType> { ... }
    fn array_overlaps<R>(
        self,
        other: R,
    ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
       where R: Expr<'a, PostgresValue<'a>>,
             Self::SQLType: ArrayOperand<R::SQLType> { ... }
}
Expand description

Method forms of the array operators, available on every PostgreSQL expression.

Each method calls the free function of the same name and has the same operand rules (ArrayOperand).

§Examples

use drizzle_core::{ToSQL, expr::raw_non_null};
use drizzle_postgres::expr::{ArrayExprExt, PgArray};
use drizzle_postgres::values::PostgresValue;
use drizzle_types::{Array, postgres::types::Text};

let tags = raw_non_null::<PostgresValue, Array<Text>>("tags");
let condition = tags.array_overlaps(PgArray(vec!["rust"]));
assert_eq!(condition.to_sql().sql(), "tags && $1");

Provided Methods§

Source

fn array_contains<R>( self, other: R, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
where R: Expr<'a, PostgresValue<'a>>, Self::SQLType: ArrayOperand<R::SQLType>,

Tests whether self contains every element of other (@>).

See array_contains.

Source

fn array_contained<R>( self, other: R, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
where R: Expr<'a, PostgresValue<'a>>, Self::SQLType: ArrayOperand<R::SQLType>,

Tests whether every element of self is in other (<@).

See array_contained.

Source

fn array_overlaps<R>( self, other: R, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, <Self::Aggregate as AggregateKind>::Or<R::Aggregate>, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
where R: Expr<'a, PostgresValue<'a>>, Self::SQLType: ArrayOperand<R::SQLType>,

Tests whether self and other share at least one element (&&).

See array_overlaps.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, E: Expr<'a, PostgresValue<'a>>> ArrayExprExt<'a> for E