Skip to content

Commit

Permalink
Add Auto Type
Browse files Browse the repository at this point in the history
  • Loading branch information
vijair committed Aug 1, 2024
1 parent 210a290 commit 9d1b6e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions diesel/src/pg/expression/helper_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 99,17 @@ pub type UnionRange<Lhs, Rhs> = Grouped<super::operators::UnionsRange<Lhs, AsExp
#[cfg(feature = "postgres_backend")]
pub type Difference<Lhs, Rhs> = Grouped<super::operators::DifferenceRange<Lhs, AsExpr<Rhs, Lhs>>>;

#[doc(hidden)] // used by `#[auto_type]`
pub type DifferenceRange<Lhs, Rhs> = Difference<Lhs, Rhs>;

/// The return type of [`lhs.intersection_range(rhs)`](super::expression_methods::PgRangeExpressionMethods::intersection_range)
#[cfg(feature = "postgres_backend")]
pub type Intersection<Lhs, Rhs> =
Grouped<super::operators::IntersectionRange<Lhs, AsExpr<Rhs, Lhs>>>;

#[doc(hidden)] // used by `#[auto_type]`
pub type IntersectionRange<Lhs, Rhs> = Intersection<Lhs, Rhs>;

/// The return type of [`expr.nulls_first()`](super::expression_methods::PgSortExpressionMethods::nulls_first)
#[cfg(feature = "postgres_backend")]
pub type NullsFirst<T> = super::operators::NullsFirst<T>;
Expand Down
15 changes: 15 additions & 0 deletions diesel_derives/tests/auto_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 288,21 @@ fn test_pg_range_expression_methods() -> _ {
.and(pg_extras::range.lesser_than(my_range))
.and(pg_extras::range.greater_than(my_range))
.and(pg_extras::range.range_not_extends_right_to(my_range))
.and(
pg_extras::range
.union_range(pg_extras::range)
.eq(pg_extras::range),
)
.and(
pg_extras::range
.difference_range(pg_extras::range)
.eq(pg_extras::range),
)
.and(
pg_extras::range
.intersection_range(pg_extras::range)
.eq(pg_extras::range),
)
// `.contains()` cannot be supported here as
// the type level constraints are slightly different
// for `Range<>` than for the other types that provide a `contains()`
Expand Down

0 comments on commit 9d1b6e4

Please sign in to comment.