Skip to content

Commit

Permalink
Merge pull request #4262 from guissalustiano/feat_improve_range_merge…
Browse files Browse the repository at this point in the history
…_type

improve range_merge type signature with new CombinedNullableValue
  • Loading branch information
weiznich authored Sep 15, 2024
2 parents bfd2e45 + 6b96f97 commit 055939f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions diesel/src/pg/expression/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ define_sql_function! {
/// # use std::collections::Bound;
/// # use diesel::sql_types::{Nullable, Integer, Array};
/// # let connection = &mut establish_connection();
/// let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(5..11, 10..)).get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;
/// assert_eq!(Some((Bound::Included(5), Bound::Unbounded)), int);
/// let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(5..11, 10..)).get_result::<(Bound<i32>, Bound<i32>)>(connection)?;
/// assert_eq!((Bound::Included(5), Bound::Unbounded), int);
///
/// let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(1..3, 7..10)).get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;
/// assert_eq!(Some((Bound::Included(1), Bound::Excluded(10))), int);
/// let int = diesel::select(range_merge::<Range<Integer>, Range<_>, _, _>(1..3, 7..10)).get_result::<(Bound<i32>, Bound<i32>)>(connection)?;
/// assert_eq!((Bound::Included(1), Bound::Excluded(10)), int);
///
/// let int = diesel::select(range_merge::<Nullable<Range<Integer>>, Nullable<Range<_>>, _, _>(None::<std::ops::Range<i32>>, 7..10)).get_result::<Option<(Bound<i32>, Bound<i32>)>>(connection)?;
/// assert_eq!(None, int);
Expand All @@ -358,7 +358,7 @@ define_sql_function! {
/// # }
/// ```
#[cfg(feature = "postgres_backend")]
fn range_merge<R1: RangeOrNullableRange + SingleValue, R2: RangeOrNullableRange<Inner=R1::Inner> + SingleValue>(lhs: R1, rhs: R2) -> Nullable<Range<R1::Inner>>;
fn range_merge<R1: RangeOrNullableRange + SingleValue, R2: RangeOrNullableRange<Inner=R1::Inner> + SingleValue + CombinedNullableValue<R1, Range<R1::Inner>>>(lhs: R1, rhs: R2) -> R2::Out;
}

define_sql_function! {
Expand Down

0 comments on commit 055939f

Please sign in to comment.