fn contains<T>(self, other: T) -> dsl::ArrayContains<Self, T>
    where
        Self::SqlType: SqlType,
        T: AsExpression<Self::SqlType>,
    {
        Grouped(Contains::new(self, other.as_expression()))
    }
/// Creates a PostgreSQL `@>` expression.
///
/// This operator returns whether an array contains another array.
///
/// # Example
///
/// ```rust
/// # include!("../../doctest_setup.rs");
/// #
/// # table! {
/// #     posts {
/// #         id -> Integer,
/// #         tags -> Array<VarChar>,
/// #     }
/// # }
/// #
/// # fn main() {
/// #     run_test().unwrap();
/// # }
/// #
/// # fn run_test() -> QueryResult<()> {
/// #     use self::posts::dsl::*;
/// #     let conn = &mut establish_connection();
/// #     conn.execute("DROP TABLE IF EXISTS posts").unwrap();
/// #     conn.execute("CREATE TABLE posts (id SERIAL PRIMARY KEY, tags TEXT[] NOT NULL)").unwrap();
/// #
/// diesel::insert_into(posts)
///     .values(tags.eq(vec!["cool", "awesome"]))
///     .execute(conn)?;
///
/// let cool_posts = posts.select(id)
///     .filter(tags.contains(vec!["cool"]))
///     .load::<i32>(conn)?;
/// assert_eq!(vec![1], cool_posts);
///
/// let amazing_posts = posts.select(id)
///     .filter(tags.contains(vec!["cool", "amazing"]))
///     .load::<i32>(conn)?;
/// assert!(amazing_posts.is_empty());
/// #     Ok(())
/// # }
/// ```
Creates a PostgreSQL `@>` expression.
This operator returns whether an array contains another array.
Creates a PostgreSQL ` @ > ` expression . This operator returns whether an array contains another array .
fn contains<T>(self, other: T) -> dsl::ArrayContains<Self, T>
    where
        Self::SqlType: SqlType,
        T: AsExpression<Self::SqlType>,
    {
        Grouped(Contains::new(self, other.as_expression()))
    }
fn contains < T > ( self , other : T ) -> dsl :: ArrayContains < Self , T > where Self :: SqlType : SqlType , T : AsExpression < Self :: SqlType > , { Grouped ( Contains :: new ( self , other . as_expression ( ) ) ) }
Creates a PostgreSQL `@>` expression.
Creates a PostgreSQL ` @ > ` expression .
self
other
T
self
other
T
example
None
include!("../../doctest_setup.rs");
None
table! {
None
posts {
None
id -> integer,
None
tags -> array<varchar>,
None
}
None
}
None
fn main() {
None
run_test().unwrap();
None
}
None
fn run_test() -> queryresult<()> {
None
use self::posts::dsl::*;
None
let conn = &mut establish_connection();
None
conn.execute("drop table if exists posts").unwrap();
None
conn.execute("create table posts (id serial primary key, tags text[] not null)").unwrap();
:insert_into(posts)
.values(tags.eq(vec!["cool", "awesome"]))
.execute(conn)?.

let cool_posts = posts.select(id)
.filter(tags.contains(vec!["cool"]))
.load::(conn)?;
assert_eq!(vec![1], cool_posts).

let amazing_posts = posts.select(id)
.filter(tags.contains(vec!["cool", "amazing"]))
.load::(conn)?;
assert!(amazing_posts.is_empty()).
: insert_into ( posts ) . values ( tags . eq ( vec! [ " cool " " awesome " ] )) . execute ( conn ) ? . let cool_posts = posts . select ( id ) . filter ( tags . contains ( vec! [ " cool " ] )) . load :: ( conn ) ? ; assert_eq! ( vec! [ 1 ] cool_posts ) . let amazing_posts = posts . select ( id ) . filter ( tags . contains ( vec! [ " cool " " amazing " ] )) . load :: ( conn ) ? ; assert! ( amazing_posts . is_empty () ) .
ok(())
None
}
None