ronantakizawa/codereview-bench huggingface dataset:
Repository: diesel-rs/diesel
File: diesel/src/sqlite/connection/serialized_database.rs (Rust)

Code before:
#![allow(unsafe_code)]
extern crate libsqlite3_sys as ffi;

/// `SerializedDatabase` is a wrapper for a serialized database that is dynamically allocated by calling `sqlite3_serialize`.
/// This RAII wrapper is necessary to deallocate the memory when it goes out of scope with `sqlite3_free`.
#[derive(Debug)]
pub struct SerializedDatabase {
    data: *mut u8,
    len: usize,
}

impl SerializedDatabase {
    /// Creates a new `SerializedDatabase` with the given data pointer and length.
    pub fn new(data: *mut u8, len: usize) -> Self {
        Self { data, len }
    }

    /// Returns a slice of the serialized database.
    pub fn as_slice(&self) -> &[u8] {
        unsafe { std::slice::from_raw_parts(self.data, self.len) }
    }
}

impl Drop for SerializedDatabase {
    /// Deallocates the memory of the serialized database when it goes out of scope.
    fn drop(&mut self) {
        unsafe {
            // Call the FFI function to free the memory
            ffi::sqlite3_free(self.data as _);
        }
    }
}


Review comment (suggestion):
I think it might be meaningful to implement `Deref<Target = [u8]>` for this wrapper type so that it can be used as `&[u8]` directly.

Code after:
#![allow(unsafe_code)]
extern crate libsqlite3_sys as ffi;

use std::ops::Deref;

/// `SerializedDatabase` is a wrapper for a serialized database that is dynamically allocated by calling `sqlite3_serialize`.
/// This RAII wrapper is necessary to deallocate the memory when it goes out of scope with `sqlite3_free`.
#[derive(Debug)]
pub struct SerializedDatabase {
    data: *mut u8,
    len: usize,
}

impl SerializedDatabase {
    /// Creates a new `SerializedDatabase` with the given data pointer and length.
    pub fn new(data: *mut u8, len: usize) -> Self {
        Self { data, len }
    }

    /// Returns a slice of the serialized database.
    pub fn as_slice(&self) -> &[u8] {
        // The pointer is never null because we don't pass the NO_COPY flag
        unsafe { std::slice::from_raw_parts(self.data, self.len) }
    }
}

impl Deref for SerializedDatabase {
    type Target = [u8];

    fn deref(&self) -> &Self::Target {
        self.as_slice()
    }
}
Repository: diesel-rs/diesel
File: diesel/src/query_builder/collected_query.rs (Rust)

Code before:
use super::{AstPass, MoveableBindCollector, Query, QueryFragment, QueryId};
use crate::backend::{Backend, DieselReserveSpecialization};
use crate::result::QueryResult;
use crate::sql_types::Untyped;

#[derive(Debug)]
#[must_use = "Queries are only executed when calling `load`, `get_result` or similar."]
/// A SQL query variant with already collected bind data which can be moved
pub struct CollectedQuery<T> {
    sql: String,
    safe_to_cache_prepared: bool,
    bind_data: T,
}

impl<T> CollectedQuery<T> {
    /// Builds a [CollectedQuery] with movable bind data
    pub fn new(sql: String, safe_to_cache_prepared: bool, bind_data: T) -> Self {
        Self {
            sql,
            safe_to_cache_prepared,
            bind_data,
        }
    }
}

impl<DB, T> QueryFragment<DB> for CollectedQuery<T>
where
    DB: Backend + DieselReserveSpecialization,
    for<'a> <DB as Backend>::BindCollector<'a>: MoveableBindCollector<DB, BindData = T>,
{
    fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
        if !self.safe_to_cache_prepared {
            pass.unsafe_to_cache_prepared();
        }
        pass.push_sql(&self.sql);
        pass.push_bind_collector_data::<T>(&self.bind_data)
    }

Review comment (suggestion):
I would like to gate that behind the `i-implement-a-third-party-backend-and-opt-into-breaking-changes` feature, as it's not useful for anyone outside of diesel-async/other crates doing really low level stuff.

Code after:
use super::{AstPass, MoveableBindCollector, Query, QueryFragment, QueryId};
use crate::backend::{Backend, DieselReserveSpecialization};
use crate::result::QueryResult;
use crate::sql_types::Untyped;

#[derive(Debug)]
#[must_use = "Queries are only executed when calling `load`, `get_result` or similar."]
/// A SQL query variant with already collected bind data which can be moved
#[diesel_derives::__diesel_public_if(
    feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub struct CollectedQuery<T> {
    sql: String,
    safe_to_cache_prepared: bool,
    bind_data: T,
}

impl<T> CollectedQuery<T> {
    /// Builds a [CollectedQuery] with movable bind data
    pub fn new(sql: String, safe_to_cache_prepared: bool, bind_data: T) -> Self {
        Self {
            sql,
            safe_to_cache_prepared,
            bind_data,
        }
    }
}

impl<DB, T> QueryFragment<DB> for CollectedQuery<T>
where
    DB: Backend + DieselReserveSpecialization,
    for<'a> <DB as Backend>::BindCollector<'a>: MoveableBindCollector<DB, BindData = T>,
{
    fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
        if !self.safe_to_cache_prepared {
            pass.unsafe_to_cache_prepared();
        }
Repository: diesel-rs/diesel
File: diesel/src/query_builder/collected_query.rs (Rust)

Code before:
use super::{AstPass, MoveableBindCollector, Query, QueryFragment, QueryId};
use crate::backend::{Backend, DieselReserveSpecialization};
use crate::result::QueryResult;
use crate::sql_types::Untyped;

#[derive(Debug)]
#[must_use = "Queries are only executed when calling `load`, `get_result` or similar."]
/// A SQL query variant with already collected bind data which can be moved
pub struct CollectedQuery<T> {
    sql: String,
    safe_to_cache_prepared: bool,
    bind_data: T,
}

impl<T> CollectedQuery<T> {
    /// Builds a [CollectedQuery] with movable bind data
    pub fn new(sql: String, safe_to_cache_prepared: bool, bind_data: T) -> Self {
        Self {
            sql,
            safe_to_cache_prepared,
            bind_data,
        }
    }
}

impl<DB, T> QueryFragment<DB> for CollectedQuery<T>
where
    DB: Backend + DieselReserveSpecialization,
    for<'a> <DB as Backend>::BindCollector<'a>: MoveableBindCollector<DB, BindData = T>,
{
    fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
        if !self.safe_to_cache_prepared {
            pass.unsafe_to_cache_prepared();
        }
        pass.push_sql(&self.sql);
        pass.push_bind_collector_data::<T>(&self.bind_data)
    }
}

impl<T> QueryId for CollectedQuery<T> {
    type QueryId = ();

    const HAS_STATIC_QUERY_ID: bool = false;
}

impl<T> Query for CollectedQuery<T> {
    type SqlType = Untyped; // FIXME set proper type of underlying original query
}


Review comment (suggestion):
We should be fine to just have a `p: PhantomData<ST>` field on the `CollectedQuery` struct which uses an additional generic type `ST`, which corresponds tho the sql type of the original query.


Code after:
        }
    }
}

impl<DB, T> QueryFragment<DB> for CollectedQuery<T>
where
    DB: Backend + DieselReserveSpecialization,
    for<'a> <DB as Backend>::BindCollector<'a>: MoveableBindCollector<DB, BindData = T>,
{
    fn walk_ast<'b>(&'b self, mut pass: AstPass<'_, 'b, DB>) -> QueryResult<()> {
        if !self.safe_to_cache_prepared {
            pass.unsafe_to_cache_prepared();
        }
        pass.push_sql(&self.sql);
        pass.push_bind_collector_data::<T>(&self.bind_data)
    }
}

impl<T> QueryId for CollectedQuery<T> {
    type QueryId = ();

    const HAS_STATIC_QUERY_ID: bool = false;
}

impl<T> Query for CollectedQuery<T> {
    type SqlType = Untyped;
}
Repository: diesel-rs/diesel
File: diesel/src/query_builder/bind_collector.rs (Rust)

Code before:
    }

    fn push_null_value(&mut self, metadata: DB::TypeMetadata) -> QueryResult<()> {
        self.metadata.push(metadata);
        self.binds.push(None);
        Ok(())
    }
}

impl<DB> MoveableBindCollector<DB> for RawBytesBindCollector<DB>
where
    for<'a> DB: Backend<BindCollector<'a> = Self> + TypeMetadata + 'static,
    <DB as TypeMetadata>::TypeMetadata: Clone + Send,
{
    type BindData = Self;

    fn moveable(&self) -> Self::BindData {
        RawBytesBindCollector {
            binds: self.binds.clone(),
            metadata: self.metadata.clone(),
        }
    }

    fn append_bind_data(&mut self, from: &Self::BindData) {
        self.binds = from.binds.clone();
        self.metadata = from.metadata.clone();
    }
}

// This is private for now as we may want to add `Into` impls for the wrapper type
// later on
mod private {
    /// A type wrapper for raw bytes
    #[derive(Debug)]
    pub struct ByteWrapper<'a>(pub(crate) &'a mut Vec<u8>);
}


Review comment (suggestion):
```suggestion
        self.binds.extend(from.binds.cloned());
        self.metadata.extend(from.metadata.clone());
```

To make this behave similar than the sqlite implementation

Code after:
    }

    fn push_null_value(&mut self, metadata: DB::TypeMetadata) -> QueryResult<()> {
        self.metadata.push(metadata);
        self.binds.push(None);
        Ok(())
    }
}

impl<DB> MoveableBindCollector<DB> for RawBytesBindCollector<DB>
where
    for<'a> DB: Backend<BindCollector<'a> = Self> + TypeMetadata + 'static,
    <DB as TypeMetadata>::TypeMetadata: Clone + Send,
{
    type BindData = Self;

    fn moveable(&self) -> Self::BindData {
        RawBytesBindCollector {
            binds: self.binds.clone(),
            metadata: self.metadata.clone(),
        }
    }

    fn append_bind_data(&mut self, from: &Self::BindData) {
        self.binds.extend(from.binds.iter().cloned());
        self.metadata.extend(from.metadata.clone());
    }
}

// This is private for now as we may want to add `Into` impls for the wrapper type
// later on
mod private {
    /// A type wrapper for raw bytes
    #[derive(Debug)]
    pub struct ByteWrapper<'a>(pub(crate) &'a mut Vec<u8>);
}
Repository: diesel-rs/diesel
File: diesel/src/sqlite/connection/sqlite_value.rs (Rust)

Code before:

#[derive(Debug)]
#[repr(transparent)]
pub(super) struct OwnedSqliteValue {
    pub(super) value: NonNull<ffi::sqlite3_value>,
}

impl Drop for OwnedSqliteValue {
    fn drop(&mut self) {
        unsafe { ffi::sqlite3_value_free(self.value.as_ptr()) }
    }
}

// Unsafe Send impl safe since sqlite3_value is built with sqlite3_value_dup
// see https://www.sqlite.org/c3ref/value.html
unsafe impl Send for OwnedSqliteValue {}

impl From<&OwnedSqliteValue> for SqliteValue<'_, '_, '_> {
    fn from(value: &OwnedSqliteValue) -> Self {
        SqliteValue {
            _row: None,
            value: value.value,
        }
    }
}

impl<'row, 'stmt, 'query> SqliteValue<'row, 'stmt, 'query> {
    pub(super) fn new(
        row: Ref<'row, PrivateSqliteRow<'stmt, 'query>>,
        col_idx: i32,
    ) -> Option<SqliteValue<'row, 'stmt, 'query>> {
        let value = match &*row {
            PrivateSqliteRow::Direct(stmt) => stmt.column_value(col_idx)?,
            PrivateSqliteRow::Duplicated { values, .. } => {
                values.get(col_idx as usize).and_then(|v| v.as_ref())?.value
            }
        };

        let ret = Self {
            _row: Some(row),
            value,
        };
        if ret.value_type().is_none() {
            None
        } else {
            Some(ret)
        }
    }

    pub(super) fn from_owned_row(
        row: &'row OwnedSqliteRow,

Review comment (suggestion):
```suggestion
```

(It's not used anymore, right?)

Code after:

#[derive(Debug)]
#[repr(transparent)]
pub(super) struct OwnedSqliteValue {
    pub(super) value: NonNull<ffi::sqlite3_value>,
}

impl Drop for OwnedSqliteValue {
    fn drop(&mut self) {
        unsafe { ffi::sqlite3_value_free(self.value.as_ptr()) }
    }
}

// Unsafe Send impl safe since sqlite3_value is built with sqlite3_value_dup
// see https://www.sqlite.org/c3ref/value.html
unsafe impl Send for OwnedSqliteValue {}

impl<'row, 'stmt, 'query> SqliteValue<'row, 'stmt, 'query> {
    pub(super) fn new(
        row: Ref<'row, PrivateSqliteRow<'stmt, 'query>>,
        col_idx: i32,
    ) -> Option<SqliteValue<'row, 'stmt, 'query>> {
        let value = match &*row {
            PrivateSqliteRow::Direct(stmt) => stmt.column_value(col_idx)?,
            PrivateSqliteRow::Duplicated { values, .. } => {
                values.get(col_idx as usize).and_then(|v| v.as_ref())?.value
            }
        };

        let ret = Self {
            _row: Some(row),
            value,
        };
        if ret.value_type().is_none() {
            None
        } else {
            Some(ret)
        }
    }

    pub(super) fn from_owned_row(
        row: &'row OwnedSqliteRow,
        col_idx: i32,
    ) -> Option<SqliteValue<'row, 'stmt, 'query>> {
        let value = row
            .values
            .get(col_idx as usize)
            .and_then(|v| v.as_ref())?
            .value;
        let ret = Self { _row: None, value };
        if ret.value_type().is_none() {
Repository: diesel-rs/diesel
File: diesel_cli/tests/print_schema.rs (Rust)

Code before:
#![allow(clippy::expect_fun_call)]
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};

use crate::support::{database, project};

#[test]
fn run_infer_schema_without_docs() {
    test_print_schema("print_schema_simple_without_docs", vec![]);
}

#[test]
fn run_except_custom_type_definitions() {
    test_print_schema(
        "print_schema_except_custom_type_definitions",
        vec!["--except-custom-type-definitions", "MyType2"],
    );
}

#[test]
fn run_infer_schema() {
    test_print_schema("print_schema_simple", vec!["--with-docs"]);
}

#[test]
fn run_infer_schema_include() {
    test_print_schema(
        "print_schema_only_tables",
        vec!["--with-docs", "-o", "users1"],
    );
}

#[test]
fn run_infer_schema_include_regex() {
    test_print_schema(
        "print_schema_only_table_regexes",
        vec!["--with-docs", "-o", "users1"],
    );
}

Review comment (bug):
This test is run for all backends but it only contains files for postgresql. That's the reason it is failing for SQLite. There are two options to fix this:
* Add the relevant test files for the other backends (SQLite, MySQL)
* add a `#[cfg(feature = "postgres")]` to the test function to mark this test as postgres only

Code after:
#![allow(clippy::expect_fun_call)]
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};

use crate::support::{database, project};

#[test]
fn run_infer_schema_without_docs() {
    test_print_schema("print_schema_simple_without_docs", vec![]);
}

#[test]
#[cfg(feature = "postgres")]
fn run_except_custom_type_definitions() {
    test_print_schema(
        "print_schema_except_custom_type_definitions",
        vec!["--except-custom-type-definitions", "MyType2"],
    );
}

#[test]
fn run_infer_schema() {
    test_print_schema("print_schema_simple", vec!["--with-docs"]);
}

#[test]
fn run_infer_schema_include() {
    test_print_schema(
        "print_schema_only_tables",
        vec!["--with-docs", "-o", "users1"],
    );
}

#[test]
fn run_infer_schema_include_regex() {
    test_print_schema(
        "print_schema_only_table_regexes",
        vec!["--with-docs", "-o", "users1"],
    );
Repository: diesel-rs/diesel
File: diesel/src/expression/cast.rs (Rust)

Code before:
    type IsAggregate = E::IsAggregate;
}

impl<E, ST, QS> SelectableExpression<QS> for Cast<E, ST>
where
    Cast<E, ST>: AppearsOnTable<QS>,
    E: SelectableExpression<QS>,
{
}

impl<E, ST, QS> AppearsOnTable<QS> for Cast<E, ST>
where
    Cast<E, ST>: Expression,
    E: AppearsOnTable<QS>,
{
}

impl<E, ST> Expression for Cast<E, ST>
where
    E: Expression,
    ST: sql_types::SingleValue,
{
    type SqlType = ST;
}
impl<E, ST, DB> query_builder::QueryFragment<DB> for Cast<E, ST>
where
    E: query_builder::QueryFragment<DB>,
    DB: diesel::backend::Backend,
    ST: KnownCastSqlTypeName<DB>,
{
    fn walk_ast<'b>(&'b self, mut out: query_builder::AstPass<'_, 'b, DB>) -> QueryResult<()> {
        out.push_sql("CAST(");
        self.expr.walk_ast(out.reborrow())?;
        out.push_sql(" AS ");
        out.push_sql(ST::sql_type_name());
        out.push_sql(")");
        Ok(())
    }
}

/// We know what to write as `sql_type` in the `CAST(expr AS sql_type)` SQL for
/// `Self`
///
/// That is what is returned by `Self::sql_type_name()`
#[diagnostic::on_unimplemented(
    note = "In order to use `CAST`, it is necessary that Diesel knows how to express the name \
		of this type in the given backend.",
    note = "This can be PRed into Diesel if the type is a standard SQL type."
)]
pub trait KnownCastSqlTypeName<DB> {
    /// What to write as `sql_type` in the `CAST(expr AS sql_type)` SQL for

Review comment (suggestion):
```suggestion

impl<E, ST, DB> query_builder::QueryFragment<DB> for Cast<E, ST>
```

Code after:
    type IsAggregate = E::IsAggregate;
}

impl<E, ST, QS> SelectableExpression<QS> for Cast<E, ST>
where
    Cast<E, ST>: AppearsOnTable<QS>,
    E: SelectableExpression<QS>,
{
}

impl<E, ST, QS> AppearsOnTable<QS> for Cast<E, ST>
where
    Cast<E, ST>: Expression,
    E: AppearsOnTable<QS>,
{
}

impl<E, ST> Expression for Cast<E, ST>
where
    E: Expression,
    ST: sql_types::SingleValue,
{
    type SqlType = ST;
}

impl<E, ST, DB> query_builder::QueryFragment<DB> for Cast<E, ST>
where
    E: query_builder::QueryFragment<DB>,
    DB: diesel::backend::Backend,
    ST: KnownCastSqlTypeName<DB>,
{
    fn walk_ast<'b>(&'b self, mut out: query_builder::AstPass<'_, 'b, DB>) -> QueryResult<()> {
        out.push_sql("CAST(");
        self.expr.walk_ast(out.reborrow())?;
        out.push_sql(" AS ");
        out.push_sql(ST::SQL_TYPE_NAME);
        out.push_sql(")");
        Ok(())
    }
}

/// We know what to write as `sql_type` in the `CAST(expr AS sql_type)` SQL for
/// `Self`
///
/// That is what is returned by `Self::sql_type_name()`
#[diagnostic::on_unimplemented(
    note = "In order to use `CAST`, it is necessary that Diesel knows how to express the name \
		of this type in the given backend.",
    note = "If you run into this error message and believe that this cast should be supported \
            open a PR that adds that trait implementation here: https://github.com/diesel-rs/diesel/blob/2fafe60a8f4ca3407dca5fe010a6092fa8a1858a/diesel/src/expression/cast.rs#L113."
)]
Repository: diesel-rs/diesel
File: diesel/src/expression/cast.rs (Rust)

Code before:
        Int8 => "integer",
        Text => "char",
    }
    diesel::sqlite::Sqlite: "sqlite" {
        Int4 => "integer",
        Int8 => "bigint",
        Text => "text",
    }
}

impl<S, E, ST> FieldAliasMapper<S> for Cast<E, ST>
where
    S: AliasSource,
    E: FieldAliasMapper<S>,
{
    type Out = Cast<<E as FieldAliasMapper<S>>::Out, ST>;
    fn map(self, alias: &query_source::Alias<S>) -> Self::Out {
        Cast {
            expr: self.expr.map(alias),
            sql_type: self.sql_type,
        }
    }
}

/// Marker trait: this SQL type (`Self`) can be casted to the target SQL type
/// (`ST`) using `CAST(expr AS target_sql_type)`
pub trait CastsTo<ST> {}
impl<ST1, ST2> CastsTo<sql_types::Nullable<ST2>> for sql_types::Nullable<ST1> where ST1: CastsTo<ST2>
{}

impl CastsTo<sql_types::Int8> for sql_types::Int4 {}
impl CastsTo<sql_types::Int4> for sql_types::Int8 {}
impl CastsTo<sql_types::Text> for sql_types::Int4 {}
impl CastsTo<sql_types::Text> for sql_types::Int8 {}


Review comment (suggestion):
```suggestion

    fn map(self, alias: &query_source::Alias<S>) -> Self::Out {
```

Code after:
        Text => "text",
        Date => "date",
        Interval => "interval",
        Time => "time",
        Timestamp => "timestamp",
    }
    diesel::mysql::Mysql: "mysql_backend" {
        Int4 => "integer",
        Int8 => "integer",
        Text => "char",
    }
    diesel::sqlite::Sqlite: "sqlite" {
        Int4 => "integer",
        Int8 => "bigint",
        Text => "text",
    }
}

impl<S, E, ST> FieldAliasMapper<S> for Cast<E, ST>
where
    S: AliasSource,
    E: FieldAliasMapper<S>,
{
    type Out = Cast<<E as FieldAliasMapper<S>>::Out, ST>;

    fn map(self, alias: &query_source::Alias<S>) -> Self::Out {
        Cast {
            expr: self.expr.map(alias),
            sql_type: self.sql_type,
        }
    }
}

/// Marker trait: this SQL type (`Self`) can be casted to the target SQL type
/// (`ST`) using `CAST(expr AS target_sql_type)`
pub trait CastsTo<ST> {}

impl<ST1, ST2> CastsTo<sql_types::Nullable<ST2>> for sql_types::Nullable<ST1> where ST1: CastsTo<ST2>
{}

impl CastsTo<sql_types::Int8> for sql_types::Int4 {}
impl CastsTo<sql_types::Int4> for sql_types::Int8 {}
impl CastsTo<sql_types::Text> for sql_types::Int4 {}
impl CastsTo<sql_types::Text> for sql_types::Int8 {}
Repository: diesel-rs/diesel
File: diesel/src/pg/expression/functions.rs (Rust)

Code before:
    /// # 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;
    /// diesel::insert_into(posts)
    ///     .values(&[
    ///        versions.eq((Bound::Included(5), Bound::Included(7))),
    ///        versions.eq((Bound::Unbounded, Bound::Included(7)))
    ///     ]).execute(conn)?;
    ///
    /// let cool_posts = posts.select(lower(versions))
    ///     .load::<Option<i32>>(conn)?;
    /// assert_eq!(vec![Some(5), None], cool_posts);
    /// #     Ok(())
    /// # }
    /// ```
    #[cfg(feature = "postgres_backend")]
    fn lower<T: RangeHelper<Inner: SingleValue> + SingleValue>(range: T) -> Nullable<<T as RangeHelper>::Inner>;
}


Review comment (suggestion):
From what I could understand, `define_sql_function` does not accept `where` clause, so I used rust [1.79 associated item bounds syntax](https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html#bounds-in-associated-type-position) to make it inline, but this breaks the MNV

Code after:
    /// # 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;
    /// diesel::insert_into(posts)
    ///     .values(&[
    ///        versions.eq((Bound::Included(5), Bound::Included(7))),
    ///        versions.eq((Bound::Unbounded, Bound::Included(7)))
    ///     ]).execute(conn)?;
    ///
    /// let cool_posts = posts.select(lower(versions))
    ///     .load::<Option<i32>>(conn)?;
    /// assert_eq!(vec![Some(5), None], cool_posts);
    /// #     Ok(())
    /// # }
    /// ```
    #[cfg(feature = "postgres_backend")]
    fn lower<T: RangeHelper>(range: T) -> Nullable<<T as RangeHelper>::Inner>;
}