Trait diesel::prelude::PgBinaryExpressionMethods

source ·
pub trait PgBinaryExpressionMethods: Expression + Sized {
    // Provided methods
    fn concat<T>(self, other: T) -> ConcatBinary<Self, T>
       where Self::SqlType: SqlType,
             T: AsExpression<Binary> { ... }
    fn like<T>(self, other: T) -> LikeBinary<Self, T>
       where Self::SqlType: SqlType,
             T: AsExpression<Binary> { ... }
    fn not_like<T>(self, other: T) -> NotLikeBinary<Self, T>
       where Self::SqlType: SqlType,
             T: AsExpression<Binary> { ... }
}
Expand description

PostgreSQL specific methods present on Binary expressions.

Provided Methods§

source

fn concat<T>(self, other: T) -> ConcatBinary<Self, T>
where Self::SqlType: SqlType, T: AsExpression<Binary>,

Concatenates two PostgreSQL byte arrays using the || operator.

§Example
let names = users.select(name.concat(" the Greatest".as_bytes())).load(connection);
let expected_names = vec![
    b"Sean the Greatest".to_vec(),
    b"Tess the Greatest".to_vec()
];
assert_eq!(Ok(expected_names), names);

// If the value is nullable, the output will be nullable
let names = users.select(hair_color.concat("ish".as_bytes())).load(connection);
let expected_names = vec![
    Some(b"Greenish".to_vec()),
    None,
];
assert_eq!(Ok(expected_names), names);
source

fn like<T>(self, other: T) -> LikeBinary<Self, T>
where Self::SqlType: SqlType, T: AsExpression<Binary>,

Creates a PostgreSQL binary LIKE expression.

This method is case sensitive. There is no case-insensitive equivalent as of PostgreSQL 14.

§Examples
let starts_with_s = users
    .select(name)
    .filter(name.like(b"S%".to_vec()))
    .load(connection);
assert_eq!(Ok(vec![b"Sean".to_vec()]), starts_with_s);
source

fn not_like<T>(self, other: T) -> NotLikeBinary<Self, T>
where Self::SqlType: SqlType, T: AsExpression<Binary>,

Creates a PostgreSQL binary LIKE expression.

This method is case sensitive. There is no case-insensitive equivalent as of PostgreSQL 14.

§Examples
let starts_with_s = users
    .select(name)
    .filter(name.not_like(b"S%".to_vec()))
    .load(connection);
assert_eq!(Ok(vec![b"Tess".to_vec()]), starts_with_s);

Object Safety§

This trait is not object safe.

Implementors§