Repository: diesel-rs/diesel
File: diesel/src/pg/expression/expression_methods.rs (Rust)

Code before:
    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)").execute(conn).unwrap();
    /// #
    /// diesel::insert_into(posts)
    ///     .values(&vec![
    ///         (versions.eq((Bound::Included(1), Bound::Included(2))))
    ///     ])
    ///     .execute(conn)?;
    ///
    /// let data = posts.select(versions.union_range((Bound::Included(2),Bound::Included(6))))
    ///     .load::<(Bound<i32>,Bound<i32>)>(conn)?;
    /// let expected_range = (Bound::Included(1),Bound::Excluded(7));
    /// assert_eq!(expected_range, data[0]);
    /// #     Ok(())
    /// # }
    /// ```
    fn union_range<T>(self, other: T) -> dsl::UnionRange<Self, T>
    where
        Self::SqlType: SqlType,
        T: AsExpression<Self::SqlType>,
    {
        Grouped(UnionsRange::new(self, other.as_expression()))
    }

    /// Creates a PostgreSQL ` - ` expression.
    ///
    /// This operator takes two ranges and returns the difference.
    ///
    /// # Example
    ///
    /// ```rust
    /// # include!("../../doctest_setup.rs");
    /// #
    /// # table! {
    /// #     posts {
    /// #         id -> Integer,
    /// #         versions -> Range<Integer>,
    /// #     }
    /// # }
    /// #
    /// # fn main() {
    /// #     run_test().unwrap();
    /// # }
    /// #
    /// # fn run_test() -> QueryResult<()> {
    /// #     use self::posts::dsl::*;
    /// #     use std::collections::Bound;
    /// #     let conn = &mut establish_connection();
    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)").execute(conn).unwrap();
    /// #
    /// diesel::insert_into(posts)

Review comment (suggestion):
```suggestion
    /// This operator takes two ranges and returns the difference.
    /// 
    /// The second range must not be contained in the first in such a way that the 
    /// difference would not be a single range.
```

Code after:
    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)").execute(conn).unwrap();
    /// #
    /// diesel::insert_into(posts)
    ///     .values(&vec![
    ///         (versions.eq((Bound::Included(1), Bound::Included(2))))
    ///     ])
    ///     .execute(conn)?;
    ///
    /// let data = posts.select(versions.union_range((Bound::Included(2),Bound::Included(6))))
    ///     .load::<(Bound<i32>,Bound<i32>)>(conn)?;
    /// let expected_range = (Bound::Included(1),Bound::Excluded(7));
    /// assert_eq!(expected_range, data[0]);
    /// #     Ok(())
    /// # }
    /// ```
    fn union_range<T>(self, other: T) -> dsl::UnionRange<Self, T>
    where
        Self::SqlType: SqlType,
        T: AsExpression<Self::SqlType>,
    {
        Grouped(UnionsRange::new(self, other.as_expression()))
    }

    /// Creates a PostgreSQL ` - ` expression.
    ///
    /// This operator takes two ranges and returns the difference.
    ///
    /// The second range must not be contained in the first in such a way that the
    /// difference would not be a single range.
    ///
    /// # Example
    ///
    /// ```rust
    /// # include!("../../doctest_setup.rs");
    /// #
    /// # table! {
    /// #     posts {
    /// #         id -> Integer,
    /// #         versions -> Range<Integer>,
    /// #     }
    /// # }
    /// #
    /// # fn main() {
    /// #     run_test().unwrap();
    /// # }
    /// #
    /// # fn run_test() -> QueryResult<()> {
    /// #     use self::posts::dsl::*;
    /// #     use std::collections::Bound;
    /// #     let conn = &mut establish_connection();
    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();