1use super::array_comparison::{AsInExpression, In, NotIn};
5use super::grouped::Grouped;
6use super::select_by::SelectBy;
7use super::{AsExpression, Expression};
8use crate::expression;
9#[cfg(any(feature = "postgres_backend", feature = "sqlite"))]
10use crate::expression_methods::JsonIndex;
11use crate::expression_methods::PreferredBoolSqlType;
12use crate::sql_types;
13
14pub type SqlTypeOf<Expr> = <Expr as Expression>::SqlType;
16
17pub type AsExpr<Item, TargetExpr> = AsExprOf<Item, SqlTypeOf<TargetExpr>>;
19
20pub type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;
22
23pub type Eq<Lhs, Rhs> = Grouped<super::operators::Eq<Lhs, AsExpr<Rhs, Lhs>>>;
26
27pub type NotEq<Lhs, Rhs> = Grouped<super::operators::NotEq<Lhs, AsExpr<Rhs, Lhs>>>;
30
31#[doc(hidden)] pub type Ne<Lhs, Rhs> = NotEq<Lhs, Rhs>;
33
34pub type EqAny<Lhs, Rhs> = Grouped<In<Lhs, <Rhs as AsInExpression<SqlTypeOf<Lhs>>>::InExpression>>;
37
38pub type NeAny<Lhs, Rhs> =
41 Grouped<NotIn<Lhs, <Rhs as AsInExpression<SqlTypeOf<Lhs>>>::InExpression>>;
42
43#[doc(hidden)] pub type NeAll<Lhs, Rhs> = NeAny<Lhs, Rhs>;
45
46pub type IsNull<Expr> = Grouped<super::operators::IsNull<Expr>>;
49
50pub type IsNotNull<Expr> = Grouped<super::operators::IsNotNull<Expr>>;
53
54pub type Gt<Lhs, Rhs> = Grouped<super::operators::Gt<Lhs, AsExpr<Rhs, Lhs>>>;
57
58pub type GtEq<Lhs, Rhs> = Grouped<super::operators::GtEq<Lhs, AsExpr<Rhs, Lhs>>>;
61
62#[doc(hidden)] pub type Ge<Lhs, Rhs> = GtEq<Lhs, Rhs>;
64
65pub type Lt<Lhs, Rhs> = Grouped<super::operators::Lt<Lhs, AsExpr<Rhs, Lhs>>>;
68
69pub type LtEq<Lhs, Rhs> = Grouped<super::operators::LtEq<Lhs, AsExpr<Rhs, Lhs>>>;
72
73#[doc(hidden)] pub type Le<Lhs, Rhs> = LtEq<Lhs, Rhs>;
75
76pub type Between<Lhs, Lower, Upper> = Grouped<
79 super::operators::Between<Lhs, super::operators::And<AsExpr<Lower, Lhs>, AsExpr<Upper, Lhs>>>,
80>;
81
82pub type NotBetween<Lhs, Lower, Upper> = Grouped<
85 super::operators::NotBetween<
86 Lhs,
87 super::operators::And<AsExpr<Lower, Lhs>, AsExpr<Upper, Lhs>>,
88 >,
89>;
90
91pub type Concat<Lhs, Rhs> = Grouped<super::operators::Concat<Lhs, AsExpr<Rhs, Lhs>>>;
94
95pub type Cast<Expr, ST> = super::cast::Cast<Expr, ST>;
98
99pub type Desc<Expr> = super::operators::Desc<Expr>;
102
103pub type Asc<Expr> = super::operators::Asc<Expr>;
106
107pub type Nullable<Expr> = super::nullable::Nullable<Expr>;
110
111pub type AssumeNotNull<Expr> = super::assume_not_null::AssumeNotNull<Expr>;
114
115pub type And<Lhs, Rhs, ST = <Rhs as PreferredBoolSqlType>::PreferredSqlType> =
118 Grouped<super::operators::And<Lhs, AsExprOf<Rhs, ST>>>;
119
120pub type Or<Lhs, Rhs, ST = <Rhs as PreferredBoolSqlType>::PreferredSqlType> =
123 Grouped<super::operators::Or<Lhs, AsExprOf<Rhs, ST>>>;
124
125pub type Escape<Lhs> = Grouped<
128 super::operators::Escape<
129 <Lhs as crate::expression_methods::EscapeExpressionMethods>::TextExpression,
130 AsExprOf<String, sql_types::VarChar>,
131 >,
132>;
133
134pub type Like<Lhs, Rhs> = Grouped<super::operators::Like<Lhs, AsExprOf<Rhs, SqlTypeOf<Lhs>>>>;
137
138pub type NotLike<Lhs, Rhs> = Grouped<super::operators::NotLike<Lhs, AsExprOf<Rhs, SqlTypeOf<Lhs>>>>;
141
142#[allow(non_camel_case_types)] pub type case_when<C, T, ST = <T as Expression>::SqlType> = expression::case_when::CaseWhen<
145 expression::case_when::CaseWhenConditionsLeaf<Grouped<C>, Grouped<AsExprOf<T, ST>>>,
146 expression::case_when::NoElseExpression,
147>;
148pub type When<W, C, T> = expression::case_when::CaseWhen<
150 expression::case_when::CaseWhenConditionsIntermediateNode<
151 Grouped<C>,
152 Grouped<AsExprOf<T, <W as expression::case_when::CaseWhenTypesExtractor>::OutputExpressionSpecifiedSqlType>>,
153 <W as expression::case_when::CaseWhenTypesExtractor>::Whens,
154 >,
155 <W as expression::case_when::CaseWhenTypesExtractor>::Else,
156>;
157pub type Otherwise<W, E> = expression::case_when::CaseWhen<
159 <W as expression::case_when::CaseWhenTypesExtractor>::Whens,
160 expression::case_when::ElseExpression<Grouped<AsExprOf<E, <W as expression::case_when::CaseWhenTypesExtractor>::OutputExpressionSpecifiedSqlType>>>,
161>;
162
163pub type AsSelect<Source, DB> = SelectBy<Source, DB>;
165
166pub type IntoSql<Item, SqlType> = AsExprOf<Item, SqlType>;
168
169pub type Field<Alias, Field> = Fields<Alias, Field>;
171
172pub type Fields<Alias, Fields> = <Fields as crate::query_source::aliasing::FieldAliasMapper<
174 <Alias as crate::query_source::aliasing::GetAliasSourceFromAlias>::Source,
175>>::Out;
176
177pub type Add<L, R> = <L as ::core::ops::Add<R>>::Output;
180
181pub type Sub<L, R> = <L as ::core::ops::Sub<R>>::Output;
184
185pub type Mul<L, R> = <L as ::core::ops::Mul<R>>::Output;
188
189pub type Div<L, R> = <L as ::core::ops::Div<R>>::Output;
192
193#[doc(inline)]
198#[allow(unreachable_pub)]
199pub use super::functions::helper_types::*;
200
201#[doc(inline)]
202#[cfg(all(feature = "postgres_backend", not(feature = "sqlite")))]
203#[allow(unreachable_pub)]
204#[cfg_attr(
205 all(feature = "sqlite", feature = "postgres_backend"),
206 expect(
207 ambiguous_glob_reexports,
208 reason = "we cannot do much about this anymore"
209 )
210)]
211pub use crate::pg::expression::helper_types::*;
212
213#[doc(inline)]
214#[cfg(all(feature = "postgres_backend", feature = "sqlite"))]
215#[allow(unreachable_pub, ambiguous_glob_reexports)]
216pub use crate::pg::expression::helper_types::*;
217
218#[doc(inline)]
219#[cfg(all(feature = "sqlite", not(feature = "postgres_backend")))]
220#[allow(unreachable_pub)]
221pub use crate::sqlite::expression::helper_types::*;
222
223#[doc(inline)]
224#[cfg(all(feature = "sqlite", feature = "postgres_backend"))]
225#[allow(unreachable_pub, ambiguous_glob_reexports)]
226pub use crate::sqlite::expression::helper_types::*;
227
228#[cfg(any(feature = "postgres_backend", feature = "sqlite"))]
230pub type RetrieveAsText<Lhs, Rhs> = Grouped<
231 crate::expression::operators::RetrieveAsTextJson<
232 Lhs,
233 AsExprOf<
234 <Rhs as JsonIndex>::Expression,
235 <<Rhs as JsonIndex>::Expression as Expression>::SqlType,
236 >,
237 >,
238>;