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§
Sourcefn concat<T>(
self,
other: T,
) -> Grouped<Concat<Self, <T as AsExpression<Self::SqlType>>::Expression>>
fn concat<T>( self, other: T, ) -> Grouped<Concat<Self, <T as AsExpression<Self::SqlType>>::Expression>>
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);Sourcefn like<T>(
self,
other: T,
) -> Grouped<Like<Self, <T as AsExpression<Self::SqlType>>::Expression>>
fn like<T>( self, other: T, ) -> Grouped<Like<Self, <T as AsExpression<Self::SqlType>>::Expression>>
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);Sourcefn not_like<T>(
self,
other: T,
) -> Grouped<NotLike<Self, <T as AsExpression<Self::SqlType>>::Expression>>
fn not_like<T>( self, other: T, ) -> Grouped<NotLike<Self, <T as AsExpression<Self::SqlType>>::Expression>>
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);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.