diesel/pg/expression/
helper_types.rs

1use crate::dsl::{AsExpr, AsExprOf, SqlTypeOf};
2use crate::expression::grouped::Grouped;
3use crate::expression::Expression;
4use crate::expression_methods::JsonIndex;
5use crate::pg::expression::expression_methods::private::JsonRemoveIndex;
6use crate::pg::types::sql_types::Array;
7use crate::sql_types::{Inet, Integer, VarChar};
8
9/// The return type of [`lhs.ilike(rhs)`](super::expression_methods::PgTextExpressionMethods::ilike)
10#[cfg(feature = "postgres_backend")]
11pub type ILike<Lhs, Rhs> = Grouped<super::operators::ILike<Lhs, AsExprOf<Rhs, VarChar>>>;
12#[doc(hidden)] // required for #[auto_type]
13pub type Ilike<Lhs, Rhs> = ILike<Lhs, Rhs>;
14
15/// The return type of [`lhs.not_ilike(rhs)`](super::expression_methods::PgTextExpressionMethods::not_ilike)
16#[cfg(feature = "postgres_backend")]
17pub type NotILike<Lhs, Rhs> = Grouped<super::operators::NotILike<Lhs, AsExprOf<Rhs, VarChar>>>;
18#[doc(hidden)] // required for #[auto_type]
19pub type NotIlike<Lhs, Rhs> = NotILike<Lhs, Rhs>;
20
21/// The return type of [`lhs.similar_to(rhs)`](super::expression_methods::PgTextExpressionMethods::similar_to)
22#[cfg(feature = "postgres_backend")]
23pub type SimilarTo<Lhs, Rhs> = Grouped<super::operators::SimilarTo<Lhs, AsExprOf<Rhs, VarChar>>>;
24
25/// The return type of [`lhs.not_similar_to(rhs)`](super::expression_methods::PgTextExpressionMethods::not_similar_to)
26#[cfg(feature = "postgres_backend")]
27pub type NotSimilarTo<Lhs, Rhs> =
28    Grouped<super::operators::NotSimilarTo<Lhs, AsExprOf<Rhs, VarChar>>>;
29
30/// The return type of [`lhs.is_not_distinct_from(rhs)`](super::expression_methods::PgExpressionMethods::is_not_distinct_from)
31#[cfg(feature = "postgres_backend")]
32pub type IsNotDistinctFrom<Lhs, Rhs> =
33    Grouped<super::operators::IsNotDistinctFrom<Lhs, AsExpr<Rhs, Lhs>>>;
34
35/// The return type of [`lhs.is_distinct_from(rhs)`](super::expression_methods::PgExpressionMethods::is_distinct_from)
36#[cfg(feature = "postgres_backend")]
37pub type IsDistinctFrom<Lhs, Rhs> =
38    Grouped<super::operators::IsDistinctFrom<Lhs, AsExpr<Rhs, Lhs>>>;
39
40/// The return type of [`lhs.overlaps_with(rhs)`](super::expression_methods::PgArrayExpressionMethods::overlaps_with)
41/// and [`lhs.overlaps_with(rhs)`](super::expression_methods::PgRangeExpressionMethods::overlaps_with)
42#[cfg(feature = "postgres_backend")]
43pub type OverlapsWith<Lhs, Rhs> = Grouped<super::operators::OverlapsWith<Lhs, AsExpr<Rhs, Lhs>>>;
44
45/// The return type of [`lhs.contains(rhs)`](super::expression_methods::PgArrayExpressionMethods::contains)
46/// for array expressions
47#[cfg(feature = "postgres_backend")]
48pub type Contains<Lhs, Rhs> = Grouped<super::operators::Contains<Lhs, AsExpr<Rhs, Lhs>>>;
49
50#[doc(hidden)]
51#[deprecated(note = "Use `Contains` instead")]
52pub type ArrayContains<Lhs, Rhs> = Contains<Lhs, Rhs>;
53
54/// The return type of [`lhs.contains(rhs)`](super::expression_methods::PgRangeExpressionMethods::contains)
55/// for range expressions
56#[cfg(feature = "postgres_backend")]
57pub type RangeContains<Lhs, Rhs> = Grouped<
58    super::operators::Contains<
59        Lhs,
60        AsExprOf<Rhs, <SqlTypeOf<Lhs> as super::expression_methods::RangeOrMultirange>::Inner>,
61    >,
62>;
63
64/// The return type of [`lhs.range_extends_right_to(rhs)`](super::expression_methods::PgRangeExpressionMethods::range_extends_right_to)
65/// for range expressions
66#[cfg(feature = "postgres_backend")]
67pub type RangeExtendsRightTo<Lhs, Rhs> =
68    Grouped<super::operators::ExtendsRightTo<Lhs, AsExpr<Rhs, Lhs>>>;
69
70/// The return type of [`lhs.range_extends_left_to(rhs)`](super::expression_methods::PgRangeExpressionMethods::range_extends_left_to)
71/// for range expressions
72#[cfg(feature = "postgres_backend")]
73pub type RangeExtendsLeftTo<Lhs, Rhs> =
74    Grouped<super::operators::ExtendsLeftTo<Lhs, AsExpr<Rhs, Lhs>>>;
75
76/// The return type of [`lhs.contains_range(rhs)`](super::expression_methods::PgRangeExpressionMethods::contains_range)
77/// for range expressions
78#[cfg(feature = "postgres_backend")]
79pub type ContainsRange<Lhs, Rhs> = Contains<Lhs, Rhs>;
80
81/// The return type of [`lhs.range_is_contained_by(rhs)`](super::expression_methods::PgRangeExpressionMethods::is_contained_by)
82/// and [`lhs.is_contained_by(rhs)`](super::expression_methods::PgArrayExpressionMethods::is_contained_by)
83#[cfg(feature = "postgres_backend")]
84pub type IsContainedBy<Lhs, Rhs> = Grouped<super::operators::IsContainedBy<Lhs, AsExpr<Rhs, Lhs>>>;
85
86/// The return type of [`lhs.is_contained_by_range(rhs)`](super::expression_methods::PgExpressionMethods::is_contained_by_range)
87#[cfg(feature = "postgres_backend")]
88pub type IsContainedByRange<Lhs, Rhs> = Grouped<
89    super::operators::IsContainedBy<Lhs, AsExprOf<Rhs, diesel::sql_types::Range<SqlTypeOf<Lhs>>>>,
90>;
91
92/// The return type of [`lhs.range_is_contained_by(rhs)`](super::expression_methods::PgRangeExpressionMethods::lesser_than)
93#[cfg(feature = "postgres_backend")]
94pub type LesserThanRange<Lhs, Rhs> =
95    Grouped<super::operators::IsContainedByNet<Lhs, AsExpr<Rhs, Lhs>>>;
96
97#[doc(hidden)] // used by `#[auto_type]`
98pub type LesserThan<Lhs, Rhs> = LesserThanRange<Lhs, Rhs>;
99
100/// The return type of [`lhs.range_is_contained_by(rhs)`](super::expression_methods::PgRangeExpressionMethods::greater_than)
101#[cfg(feature = "postgres_backend")]
102pub type GreaterThanRange<Lhs, Rhs> = Grouped<super::operators::ContainsNet<Lhs, AsExpr<Rhs, Lhs>>>;
103
104#[doc(hidden)] // used by `#[auto_type]`
105pub type GreaterThan<Lhs, Rhs> = GreaterThanRange<Lhs, Rhs>;
106
107/// The return type of [`lhs.union_range(rhs)`](super::expression_methods::PgRangeExpressionMethods::union_range)
108#[cfg(feature = "postgres_backend")]
109pub type UnionRange<Lhs, Rhs> = Grouped<super::operators::UnionsRange<Lhs, AsExpr<Rhs, Lhs>>>;
110
111/// The return type of [`lhs.difference_range(rhs)`](super::expression_methods::PgRangeExpressionMethods::difference_range)
112#[cfg(feature = "postgres_backend")]
113pub type Difference<Lhs, Rhs> = Grouped<super::operators::DifferenceRange<Lhs, AsExpr<Rhs, Lhs>>>;
114
115#[doc(hidden)] // used by `#[auto_type]`
116pub type DifferenceRange<Lhs, Rhs> = Difference<Lhs, Rhs>;
117
118/// The return type of [`lhs.range_adjacent(rhs)`](super::expression_methods::PgRangeExpressionMethods::range_adjacent)
119#[cfg(feature = "postgres_backend")]
120pub type RangeAdjacent<Lhs, Rhs> = Grouped<super::operators::RangeAdjacent<Lhs, AsExpr<Rhs, Lhs>>>;
121
122/// The return type of [`lhs.intersection_range(rhs)`](super::expression_methods::PgRangeExpressionMethods::intersection_range)
123#[cfg(feature = "postgres_backend")]
124pub type Intersection<Lhs, Rhs> =
125    Grouped<super::operators::IntersectionRange<Lhs, AsExpr<Rhs, Lhs>>>;
126
127#[doc(hidden)] // used by `#[auto_type]`
128pub type IntersectionRange<Lhs, Rhs> = Intersection<Lhs, Rhs>;
129
130/// The return type of [`expr.nulls_first()`](super::expression_methods::PgSortExpressionMethods::nulls_first)
131#[cfg(feature = "postgres_backend")]
132pub type NullsFirst<T> = super::operators::NullsFirst<T>;
133
134/// The return type of [`expr.is_json()`](super::expression_methods::PgTextExpressionMethods::is_json())
135#[cfg(feature = "postgres_backend")]
136pub type IsJson<T> = super::operators::IsJson<T>;
137
138/// The return type of [`expr.is_not_json()`](super::expression_methods::PgTextExpressionMethods::is_not_json())
139#[cfg(feature = "postgres_backend")]
140pub type IsNotJson<T> = super::operators::IsNotJson<T>;
141
142/// The return type of [`expr.is_json_object()`](super::expression_methods::PgTextExpressionMethods::is_json_object())
143#[cfg(feature = "postgres_backend")]
144pub type IsJsonObject<T> = super::operators::IsJsonObject<T>;
145
146/// The return type of [`expr.is_not_json_object()`](super::expression_methods::PgTextExpressionMethods::is_not_json_object())
147#[cfg(feature = "postgres_backend")]
148pub type IsNotJsonObject<T> = super::operators::IsNotJsonObject<T>;
149
150/// The return type of [`expr.is_json_array()`](super::expression_methods::PgTextExpressionMethods::is_json_array())
151#[cfg(feature = "postgres_backend")]
152pub type IsJsonArray<T> = super::operators::IsJsonArray<T>;
153
154/// The return type of [`expr.is_not_json_array()`](super::expression_methods::PgTextExpressionMethods::is_not_json_array())
155#[cfg(feature = "postgres_backend")]
156pub type IsNotJsonArray<T> = super::operators::IsNotJsonArray<T>;
157
158/// The return type of [`expr.is_json_scalar()`](super::expression_methods::PgTextExpressionMethods::is_json_scalar())
159#[cfg(feature = "postgres_backend")]
160pub type IsJsonScalar<T> = super::operators::IsJsonScalar<T>;
161
162/// The return type of [`expr.is_not_json_scalar()`](super::expression_methods::PgTextExpressionMethods::is_not_json_scalar())
163#[cfg(feature = "postgres_backend")]
164pub type IsNotJsonScalar<T> = super::operators::IsNotJsonScalar<T>;
165
166/// The return type of [`expr.nulls_last()`](super::expression_methods::PgSortExpressionMethods::nulls_last())
167#[cfg(feature = "postgres_backend")]
168pub type NullsLast<T> = super::operators::NullsLast<T>;
169
170/// The return type of [`expr.at_time_zone(tz)`](super::expression_methods::PgTimestampExpressionMethods::at_time_zone())
171#[cfg(feature = "postgres_backend")]
172pub type AtTimeZone<Lhs, Rhs> =
173    Grouped<super::date_and_time::AtTimeZone<Lhs, AsExprOf<Rhs, VarChar>>>;
174
175/// The return type of [`lhs.contains(rhs)`](super::expression_methods::PgNetExpressionMethods::contains())
176/// for network types
177#[cfg(feature = "postgres_backend")]
178pub type ContainsNet<Lhs, Rhs> = Grouped<super::operators::ContainsNet<Lhs, AsExprOf<Rhs, Inet>>>;
179
180/// The return type of [`lhs.contains_or_eq(rhs)`](super::expression_methods::PgNetExpressionMethods::contains_or_eq)
181#[cfg(feature = "postgres_backend")]
182pub type ContainsNetLoose<Lhs, Rhs> =
183    Grouped<super::operators::ContainsNetLoose<Lhs, AsExprOf<Rhs, Inet>>>;
184
185#[doc(hidden)] // used by `#[auto_type]`
186pub type ContainsOrEq<Lhs, Rhs> = ContainsNetLoose<Lhs, Rhs>;
187
188/// The return type of [`lhs.is_contained_by(rhs)`](super::expression_methods::PgNetExpressionMethods::is_contained_by)
189/// for network types
190#[cfg(feature = "postgres_backend")]
191pub type IsContainedByNet<Lhs, Rhs> =
192    Grouped<super::operators::IsContainedByNet<Lhs, AsExprOf<Rhs, Inet>>>;
193
194/// The return type of [`lhs.is_contained_by_or_eq(rhs)`](super::expression_methods::PgNetExpressionMethods::is_contained_by_or_eq)
195#[cfg(feature = "postgres_backend")]
196pub type IsContainedByNetLoose<Lhs, Rhs> =
197    Grouped<super::operators::IsContainedByNetLoose<Lhs, AsExprOf<Rhs, Inet>>>;
198
199#[doc(hidden)] // is used by `#[auto_type]`
200pub type IsContainedByOrEq<Lhs, Rhs> = IsContainedByNetLoose<Lhs, Rhs>;
201
202/// The return type of [`lhs.overlaps_with(rhs)`](super::expression_methods::PgNetExpressionMethods::overlaps_with)
203/// for network types
204#[cfg(feature = "postgres_backend")]
205pub type OverlapsWithNet<Lhs, Rhs> =
206    Grouped<super::operators::OverlapsWith<Lhs, AsExprOf<Rhs, Inet>>>;
207
208/// The return type of [`lsh.and(rhs)`](super::expression_methods::PgNetExpressionMethods::and) for network types
209#[cfg(feature = "postgres_backend")]
210pub type AndNet<Lhs, Rhs> = Grouped<super::operators::AndNet<Lhs, AsExprOf<Rhs, Inet>>>;
211
212/// The return type of [`lsh.or(rhs)`](super::expression_methods::PgNetExpressionMethods::or) for network types
213#[cfg(feature = "postgres_backend")]
214pub type OrNet<Lhs, Rhs> = Grouped<super::operators::OrNet<Lhs, AsExprOf<Rhs, Inet>>>;
215
216/// The return type of [`lsh.diff(rhs)`](super::expression_methods::PgNetExpressionMethods::diff)
217#[cfg(feature = "postgres_backend")]
218pub type DifferenceNet<Lhs, Rhs> =
219    Grouped<super::operators::DifferenceNet<Lhs, AsExprOf<Rhs, Inet>>>;
220
221#[doc(hidden)] // used by `#[auto_type]`
222pub type Diff<Lhs, Rhs> = DifferenceNet<Lhs, Rhs>;
223
224#[doc(hidden)]
225#[deprecated(note = "Use `dsl::Concat` instead")]
226pub type ConcatJsonb<Lhs, Rhs> = crate::dsl::Concat<Lhs, Rhs>;
227
228/// The return type of [`lsh.has_key(rhs)`](super::expression_methods::PgJsonbExpressionMethods::has_key)
229#[cfg(feature = "postgres_backend")]
230pub type HasKeyJsonb<Lhs, Rhs> =
231    Grouped<super::operators::HasKeyJsonb<Lhs, AsExprOf<Rhs, VarChar>>>;
232
233#[doc(hidden)] // needed for `#[auto_type]`
234pub type HasKey<Lhs, Rhs> = HasKeyJsonb<Lhs, Rhs>;
235
236/// The return type of [`lsh.has_any_key(rhs)`](super::expression_methods::PgJsonbExpressionMethods::has_any_key)
237#[cfg(feature = "postgres_backend")]
238pub type HasAnyKeyJsonb<Lhs, Rhs> =
239    Grouped<super::operators::HasAnyKeyJsonb<Lhs, AsExprOf<Rhs, Array<VarChar>>>>;
240
241#[doc(hidden)] // needed for `#[auto_type]`
242pub type HasAnyKey<Lhs, Rhs> = HasAnyKeyJsonb<Lhs, Rhs>;
243
244/// The return type of [`lsh.has_all_keys(rhs)`](super::expression_methods::PgJsonbExpressionMethods::has_all_keys)
245#[cfg(feature = "postgres_backend")]
246pub type HasAllKeysJsonb<Lhs, Rhs> =
247    Grouped<super::operators::HasAllKeysJsonb<Lhs, AsExprOf<Rhs, Array<VarChar>>>>;
248
249#[doc(hidden)] // needed for `#[auto_type]`
250pub type HasAllKeys<Lhs, Rhs> = HasAllKeysJsonb<Lhs, Rhs>;
251
252#[doc(hidden)]
253#[deprecated(note = "Use `dsl::Contains` instead")]
254pub type ContainsJsonb<Lhs, Rhs> = Contains<Lhs, Rhs>;
255
256#[doc(hidden)]
257#[deprecated(note = "Use `dsl::IsContainedBy` instead")]
258pub type IsContainedByJsonb<Lhs, Rhs> = IsContainedBy<Lhs, Rhs>;
259
260/// The return type of [`lhs.index(rhs)`](super::expression_methods::PgArrayExpressionMethods::index)
261#[cfg(feature = "postgres_backend")]
262pub type Index<Lhs, Rhs> = super::operators::ArrayIndex<Lhs, AsExprOf<Rhs, Integer>>;
263
264#[doc(hidden)]
265#[deprecated(note = "Use `Index` instead")]
266pub type ArrayIndex<Lhs, Rhs> = Index<Lhs, Rhs>;
267
268/// The return type of [`lhs.remove(rhs)`](super::expression_methods::PgJsonbExpressionMethods::remove)
269#[cfg(feature = "postgres_backend")]
270pub type RemoveFromJsonb<Lhs, Rhs, ST> =
271    Grouped<super::operators::RemoveFromJsonb<Lhs, AsExprOf<Rhs, ST>>>;
272
273#[doc(hidden)] // needed for `#[auto_type]`
274pub type Remove<Lhs, Rhs> = RemoveFromJsonb<
275    Lhs,
276    <Rhs as JsonRemoveIndex>::Expression,
277    <<Rhs as JsonRemoveIndex>::Expression as Expression>::SqlType,
278>;
279
280#[doc(hidden)] // deprecated
281pub type RetrieveAsObjectJson<Lhs, Rhs, ST> =
282    Grouped<crate::pg::expression::operators::RetrieveAsObjectJson<Lhs, AsExprOf<Rhs, ST>>>;
283
284/// The return type of [`lhs.retrieve_as_object(rhs)`](super::expression_methods::PgAnyJsonExpressionMethods::retrieve_as_object)
285#[cfg(feature = "postgres_backend")]
286pub type RetrieveAsObject<Lhs, Rhs> = Grouped<
287    crate::pg::expression::operators::RetrieveAsObjectJson<
288        Lhs,
289        AsExprOf<
290            <Rhs as JsonIndex>::Expression,
291            <<Rhs as JsonIndex>::Expression as Expression>::SqlType,
292        >,
293    >,
294>;
295
296#[doc(hidden)] // deprecated
297pub type RetrieveAsTextJson<Lhs, Rhs, ST> =
298    Grouped<crate::expression::operators::RetrieveAsTextJson<Lhs, AsExprOf<Rhs, ST>>>;
299
300/// The return type of [`lhs.retrieve_by_path_as_object(rhs)`](super::expression_methods::PgAnyJsonExpressionMethods::retrieve_by_path_as_object)
301#[cfg(feature = "postgres_backend")]
302pub type RetrieveByPathAsObjectJson<Lhs, Rhs> =
303    Grouped<super::operators::RetrieveByPathAsObjectJson<Lhs, AsExprOf<Rhs, Array<VarChar>>>>;
304
305#[doc(hidden)] // needed for `#[auto_type]`
306pub type RetrieveByPathAsObject<Lhs, Rhs> = RetrieveByPathAsObjectJson<Lhs, Rhs>;
307
308/// The return type of [`lhs.retrieve_by_path_as_text(rhs)`](super::expression_methods::PgAnyJsonExpressionMethods::retrieve_by_path_as_text)
309#[cfg(feature = "postgres_backend")]
310pub type RetrieveByPathAsTextJson<Lhs, Rhs> =
311    Grouped<super::operators::RetrieveByPathAsTextJson<Lhs, AsExprOf<Rhs, Array<VarChar>>>>;
312
313#[doc(hidden)] // needed for `#[auto_type]`
314pub type RetrieveByPathAsText<Lhs, Rhs> = RetrieveByPathAsTextJson<Lhs, Rhs>;
315
316/// The return type of [`lhs.remove_by_path(rhs)`](super::expression_methods::PgJsonbExpressionMethods::remove_by_path)
317#[cfg(feature = "postgres_backend")]
318pub type RemoveByPathFromJsonb<Lhs, Rhs> =
319    Grouped<super::operators::RemoveByPathFromJsonb<Lhs, AsExprOf<Rhs, Array<VarChar>>>>;
320
321#[doc(hidden)] // needed for `#[auto_type]`
322pub type RemoveByPath<Lhs, Rhs> = RemoveByPathFromJsonb<Lhs, Rhs>;
323
324#[doc(hidden)]
325#[deprecated(note = "Use `dsl::Concat` instead")]
326pub type ConcatBinary<Lhs, Rhs> = crate::dsl::Concat<Lhs, Rhs>;
327
328#[doc(hidden)]
329#[deprecated(note = "Use `dsl::Like` instead")]
330pub type LikeBinary<Lhs, Rhs> = crate::dsl::Like<Lhs, Rhs>;
331
332#[doc(hidden)]
333#[deprecated(note = "Use `dsl::NotLike` instead")]
334pub type NotLikeBinary<Lhs, Rhs> = crate::dsl::NotLike<Lhs, Rhs>;
335
336#[doc(hidden)]
337#[deprecated(note = "Use `dsl::Concat` instead")]
338pub type ConcatArray<Lhs, Rhs> = crate::dsl::Concat<Lhs, Rhs>;
339
340#[doc(inline)]
341pub use super::return_type_helpers::*;