Skip to content

Commit

Permalink
lower_inf
Browse files Browse the repository at this point in the history
  • Loading branch information
guissalustiano committed Jul 13, 2024
1 parent f79dc0a commit fa42891
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions diesel/src/pg/expression/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 275,48 @@ define_sql_function! {
fn upper_inc<T: RangeHelper>(range: T) -> Bool;
}

define_sql_function! {
/// Returns if the range's lower bound inclusive.
/// # 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();
/// #
/// use diesel::dsl::lower_inf;
/// diesel::insert_into(posts)
/// .values(&[
/// versions.eq((Bound::Included(5), Bound::Excluded(7))),
/// versions.eq((Bound::Unbounded, Bound::Excluded(7))),
/// ]).execute(conn)?;
///
/// let cool_posts = posts.select(lower_inf(versions))
/// .load::<bool>(conn)?;
/// assert_eq!(vec![false, true], cool_posts);
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "postgres_backend")]
fn lower_inf<T: RangeHelper>(range: T) -> Bool;
}

define_sql_function! {
/// Returns range of integer.
/// # Example
Expand Down

0 comments on commit fa42891

Please sign in to comment.