use expression::operators::{Concat, Like, NotLike};
use expression::{AsExpression, Expression};
use sql_types::{Nullable, Text};
pub trait TextExpressionMethods: Expression + Sized {
fn concat<T: AsExpression<Self::SqlType>>(self, other: T) -> Concat<Self, T::Expression> {
Concat::new(self, other.as_expression())
}
fn like<T: AsExpression<Self::SqlType>>(self, other: T) -> Like<Self, T::Expression> {
Like::new(self.as_expression(), other.as_expression())
}
fn not_like<T: AsExpression<Self::SqlType>>(self, other: T) -> NotLike<Self, T::Expression> {
NotLike::new(self.as_expression(), other.as_expression())
}
}
#[doc(hidden)]
pub trait TextOrNullableText {}
impl TextOrNullableText for Text {}
impl TextOrNullableText for Nullable<Text> {}
impl<T> TextExpressionMethods for T
where
T: Expression,
T::SqlType: TextOrNullableText,
{
}