diff --git a/diesel/src/pg/expression/expression_methods.rs b/diesel/src/pg/expression/expression_methods.rs index ce1664543cb6..b48f9c2a5279 100644 --- a/diesel/src/pg/expression/expression_methods.rs +++ b/diesel/src/pg/expression/expression_methods.rs @@ -4,7 +4,7 @@ pub(in crate::pg) use self::private::{ ArrayOrNullableArray, InetOrCidr, JsonIndex, JsonOrNullableJson, JsonOrNullableJsonOrJsonbOrNullableJsonb, JsonRemoveIndex, JsonbOrNullableJsonb, MaybeNullableValue, MultirangeOrNullableMultirange, MultirangeOrRangeMaybeNullable, - RangeHelper, RangeOrNullableRange, TextArrayOrNullableTextArray, TextOrNullableText, + RangeOrMultirange, RangeOrNullableRange, TextArrayOrNullableTextArray, TextOrNullableText, }; use super::date_and_time::{AtTimeZone, DateTimeLike}; use super::operators::*; @@ -868,9 +868,9 @@ pub trait PgRangeExpressionMethods: Expression + Sized { /// ``` fn contains(self, other: T) -> dsl::RangeContains where - Self::SqlType: RangeHelper, - ::Inner: SqlType + TypedExpressionType, - T: AsExpression<::Inner>, + Self::SqlType: RangeOrMultirange, + ::Inner: SqlType + TypedExpressionType, + T: AsExpression<::Inner>, { Grouped(Contains::new(self, other.as_expression())) } @@ -1779,7 +1779,7 @@ pub trait PgRangeExpressionMethods: Expression + Sized { impl PgRangeExpressionMethods for T where T: Expression, - T::SqlType: RangeOrNullableRange, + T::SqlType: MultirangeOrRangeMaybeNullable, { } @@ -3466,12 +3466,20 @@ pub(in crate::pg) mod private { impl TextOrNullableText for Nullable {} /// Marker trait used to extract the inner type - /// of our `Range` sql type, used to implement `PgRangeExpressionMethods` - pub trait RangeHelper: SqlType + SingleValue { + /// of our `Range` and `Multirange` sql type, used to implement `PgRangeExpressionMethods` + pub trait RangeOrMultirange: SqlType + SingleValue { type Inner: SingleValue; } - impl RangeHelper for Range + impl RangeOrMultirange for Range + where + Self: 'static, + ST: SingleValue, + { + type Inner = ST; + } + + impl RangeOrMultirange for Multirange where Self: 'static, ST: SingleValue, diff --git a/diesel/src/pg/expression/helper_types.rs b/diesel/src/pg/expression/helper_types.rs index 3e757b08872b..c06484306988 100644 --- a/diesel/src/pg/expression/helper_types.rs +++ b/diesel/src/pg/expression/helper_types.rs @@ -56,7 +56,7 @@ pub type ArrayContains = Contains; pub type RangeContains = Grouped< super::operators::Contains< Lhs, - AsExprOf as super::expression_methods::RangeHelper>::Inner>, + AsExprOf as super::expression_methods::RangeOrMultirange>::Inner>, >, >;