Trait block_tools::db::use_diesel::PgArrayExpressionMethods [−][src]
PostgreSQL specific methods present on array expressions.
Provided methods
pub fn overlaps_with<T>(
self,
other: T
) -> OverlapsWith<Self, <T as AsExpression<Self::SqlType>>::Expression> where
T: AsExpression<Self::SqlType>,
[src]
self,
other: T
) -> OverlapsWith<Self, <T as AsExpression<Self::SqlType>>::Expression> where
T: AsExpression<Self::SqlType>,
Creates a PostgreSQL &&
expression.
This operator returns whether two arrays have common elements.
Example
diesel::insert_into(posts) .values(&vec![ tags.eq(vec!["cool", "awesome"]), tags.eq(vec!["awesome", "great"]), tags.eq(vec!["cool", "great"]), ]) .execute(&conn)?; let data = posts.select(id) .filter(tags.overlaps_with(vec!["horrid", "cool"])) .load::<i32>(&conn)?; assert_eq!(vec![1, 3], data); let data = posts.select(id) .filter(tags.overlaps_with(vec!["cool", "great"])) .load::<i32>(&conn)?; assert_eq!(vec![1, 2, 3], data); let data = posts.select(id) .filter(tags.overlaps_with(vec!["horrid"])) .load::<i32>(&conn)?; assert!(data.is_empty());
pub fn contains<T>(
self,
other: T
) -> Contains<Self, <T as AsExpression<Self::SqlType>>::Expression> where
T: AsExpression<Self::SqlType>,
[src]
self,
other: T
) -> Contains<Self, <T as AsExpression<Self::SqlType>>::Expression> where
T: AsExpression<Self::SqlType>,
Creates a PostgreSQL @>
expression.
This operator returns whether an array contains another array.
Example
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());
pub fn is_contained_by<T>(
self,
other: T
) -> IsContainedBy<Self, <T as AsExpression<Self::SqlType>>::Expression> where
T: AsExpression<Self::SqlType>,
[src]
self,
other: T
) -> IsContainedBy<Self, <T as AsExpression<Self::SqlType>>::Expression> where
T: AsExpression<Self::SqlType>,
Creates a PostgreSQL <@
expression.
This operator returns whether an array is contained by another array.
foo.contains(bar)
is the same as bar.is_contained_by(foo)
Example
diesel::insert_into(posts) .values(tags.eq(vec!["cool", "awesome"])) .execute(&conn)?; let data = posts.select(id) .filter(tags.is_contained_by(vec!["cool", "awesome", "amazing"])) .load::<i32>(&conn)?; assert_eq!(vec![1], data); let data = posts.select(id) .filter(tags.is_contained_by(vec!["cool"])) .load::<i32>(&conn)?; assert!(data.is_empty());
Implementors
impl<T, ST> PgArrayExpressionMethods<ST> for T where
T: Expression<SqlType = Array<ST>>,
[src]
T: Expression<SqlType = Array<ST>>,