pub trait TextExpressionMethods: Sized + Expression {
    // Provided methods
    fn concat<T>(
        self,
        other: T,
    ) -> Grouped<Concat<Self, <T as AsExpression<Self::SqlType>>::Expression>>
       where Self::SqlType: SqlType,
             T: AsExpression<Self::SqlType> { ... }
    fn like<T>(
        self,
        other: T,
    ) -> Grouped<Like<Self, <T as AsExpression<Self::SqlType>>::Expression>>
       where Self::SqlType: SqlType,
             T: AsExpression<Self::SqlType> { ... }
    fn not_like<T>(
        self,
        other: T,
    ) -> Grouped<NotLike<Self, <T as AsExpression<Self::SqlType>>::Expression>>
       where Self::SqlType: SqlType,
             T: AsExpression<Self::SqlType> { ... }
}
Expand description

Methods present on text expressions

Provided Methods§

source

fn concat<T>( self, other: T, ) -> Grouped<Concat<Self, <T as AsExpression<Self::SqlType>>::Expression>>
where Self::SqlType: SqlType, T: AsExpression<Self::SqlType>,

Concatenates two strings using the || operator.

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

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

fn like<T>( self, other: T, ) -> Grouped<Like<Self, <T as AsExpression<Self::SqlType>>::Expression>>
where Self::SqlType: SqlType, T: AsExpression<Self::SqlType>,

Returns a SQL LIKE expression

This method is case insensitive for SQLite and MySQL. On PostgreSQL, LIKE is case sensitive. You may use ilike() for case insensitive comparison on PostgreSQL.

§Examples
let starts_with_s = users
    .select(name)
    .filter(name.like("S%"))
    .load::<String>(connection)?;
assert_eq!(vec!["Sean"], starts_with_s);
source

fn not_like<T>( self, other: T, ) -> Grouped<NotLike<Self, <T as AsExpression<Self::SqlType>>::Expression>>
where Self::SqlType: SqlType, T: AsExpression<Self::SqlType>,

Returns a SQL NOT LIKE expression

This method is case insensitive for SQLite and MySQL. On PostgreSQL NOT LIKE is case sensitive. You may use not_ilike() for case insensitive comparison on PostgreSQL.

§Examples
let doesnt_start_with_s = users
    .select(name)
    .filter(name.not_like("S%"))
    .load::<String>(connection)?;
assert_eq!(vec!["Tess"], doesnt_start_with_s);

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> TextExpressionMethods for T
where T: Expression, <T as Expression>::SqlType: TextOrNullableText,