use super::PgBinOper;
use crate::{
ColumnRef, Expr, ExprTrait, FunctionCall, IntoLikeExpr, Keyword, LikeExpr, SimpleExpr, Value,
};
pub trait PgExpr: ExprTrait {
fn concatenate<T>(self, right: T) -> SimpleExpr
where
T: Into<SimpleExpr>,
{
self.binary(PgBinOper::Concatenate, right)
}
fn concat<T>(self, right: T) -> SimpleExpr
where
T: Into<SimpleExpr>,
{
self.concatenate(right)
}
fn matches<T>(self, expr: T) -> SimpleExpr
where
T: Into<SimpleExpr>,
{
self.binary(PgBinOper::Matches, expr)
}
fn contains<T>(self, expr: T) -> SimpleExpr
where
T: Into<SimpleExpr>,
{
self.binary(PgBinOper::Contains, expr)
}
fn contained<T>(self, expr: T) -> SimpleExpr
where
T: Into<SimpleExpr>,
{
self.binary(PgBinOper::Contained, expr)
}
fn ilike<L>(self, like: L) -> SimpleExpr
where
L: IntoLikeExpr,
{
self.binary(PgBinOper::ILike, like.into_like_expr())
}
fn not_ilike<L>(self, like: L) -> SimpleExpr
where
L: IntoLikeExpr,
{
self.binary(PgBinOper::NotILike, like.into_like_expr())
}
fn get_json_field<T>(self, right: T) -> SimpleExpr
where
T: Into<SimpleExpr>,
{
self.binary(PgBinOper::GetJsonField, right)
}
fn cast_json_field<T>(self, right: T) -> SimpleExpr
where
T: Into<SimpleExpr>,
{
self.binary(PgBinOper::CastJsonField, right)
}
}
impl PgExpr for Expr {}
impl PgExpr for SimpleExpr {}
impl PgExpr for FunctionCall {}
impl PgExpr for ColumnRef {}
impl PgExpr for Keyword {}
impl PgExpr for LikeExpr {}
impl PgExpr for Value {}