ronantakizawa/codereview-bench huggingface dataset:
Repository: diesel-rs/diesel
File: diesel_derives/tests/auto_type.rs (Rust)

Code before:
    }
}

table! {
    posts3 {
        id -> Integer,
        user_id -> Integer,
    }
}

#[cfg(feature = "postgres")]
table! {
    pg_extras(id) {
        id -> Integer,
        json -> Json,
        jsonb -> Jsonb,
        net -> Inet,
        array -> Array<Integer>,
        blob -> Binary,
        timestamp -> Timestamp,
        range -> Range<Integer>,
        multirange -> Multirange<Integer>,
        timestamptz -> Timestamptz,
        name -> Text,
        text_array -> Array<Text>,
        record -> Record,
    }
}

joinable!(posts -> users(user_id));
joinable!(posts2 -> users(user_id));
joinable!(posts3 -> users(user_id));
allow_tables_to_appear_in_same_query!(users, posts, posts2, posts3);

#[auto_type]
fn test_all_query_dsl() -> _ {
    users::table
        .distinct()
        .filter(users::id.eq(42_i32))
        .find(42_i32)
        .or_filter(users::id.eq(42_i32))
        .limit(23_i64)
        .offset(12_i64)
        .order(users::id)
        .order_by(users::id)
        .then_order_by(users::id)
        .select(users::id)
        .group_by(users::id)
        .having(users::id.eq(32_i32))
        .inner_join(posts::table)
        .left_join(posts2::table)

Review comment (suggestion):
We would need to define the record type here as `Record<(Integer, Text)>` or something like that to fix the compiler error.

Code after:
    }
}

table! {
    posts3 {
        id -> Integer,
        user_id -> Integer,
    }
}

#[cfg(feature = "postgres")]
table! {
    pg_extras(id) {
        id -> Integer,
        json -> Json,
        jsonb -> Jsonb,
        net -> Inet,
        array -> Array<Integer>,
        blob -> Binary,
        timestamp -> Timestamp,
        range -> Range<Integer>,
        multirange -> Multirange<Integer>,
        timestamptz -> Timestamptz,
        name -> Text,
        text_array -> Array<Text>,
        record -> Record<(Integer, Text, Date)>,
    }
}

joinable!(posts -> users(user_id));
joinable!(posts2 -> users(user_id));
joinable!(posts3 -> users(user_id));
allow_tables_to_appear_in_same_query!(users, posts, posts2, posts3);

#[auto_type]
fn test_all_query_dsl() -> _ {
    users::table
        .distinct()
        .filter(users::id.eq(42_i32))
        .find(42_i32)
        .or_filter(users::id.eq(42_i32))
        .limit(23_i64)
        .offset(12_i64)
        .order(users::id)
        .order_by(users::id)
        .then_order_by(users::id)
        .select(users::id)
        .group_by(users::id)
        .having(users::id.eq(32_i32))
        .inner_join(posts::table)
        .left_join(posts2::table)
Repository: diesel-rs/diesel
File: diesel_tests/tests/types.rs (Rust)

Code before:
    let expected_value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03];
    assert_eq!(
        expected_value,
        query_single_value::<MacAddr, [u8; 6]>(query)
    );
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03'::macaddr";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03];
    assert!(query_to_sql_equality::<MacAddr, [u8; 6]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_from_sql() {
    let query = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let expected_value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert_eq!(
        expected_value,
        query_single_value::<MacAddr, [u8; 8]>(query)
    );
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert!(query_to_sql_equality::<MacAddr, [u8; 8]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_v4address_from_sql() {
    extern crate ipnetwork;
    use std::str::FromStr;

    let query = "'192.168.1.0/24'::cidr";
    let expected_value =
        ipnetwork::IpNetwork::V4(ipnetwork::Ipv4Network::from_str("192.168.1.0/24").unwrap());
    assert_eq!(
        expected_value,

Review comment (suggestion):
```suggestion
        query_single_value::<MacAddr8, [u8; 8]>(query)
```

Code after:
    let expected_value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03];
    assert_eq!(
        expected_value,
        query_single_value::<MacAddr, [u8; 6]>(query)
    );
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03'::macaddr";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03];
    assert!(query_to_sql_equality::<MacAddr, [u8; 6]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_from_sql() {
    let query = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let expected_value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert_eq!(
        expected_value,
        query_single_value::<MacAddr8, [u8; 8]>(query)
    );
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert!(query_to_sql_equality::<MacAddr8, [u8; 8]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_v4address_from_sql() {
    extern crate ipnetwork;
    use std::str::FromStr;

    let query = "'192.168.1.0/24'::cidr";
    let expected_value =
        ipnetwork::IpNetwork::V4(ipnetwork::Ipv4Network::from_str("192.168.1.0/24").unwrap());
    assert_eq!(
        expected_value,
Repository: diesel-rs/diesel
File: diesel_tests/tests/types_roundtrip.rs (Rust)

Code before:
    );
    test_round_trip!(
        uuid_roundtrips,
        Uuid,
        (u32, u16, u16, (u8, u8, u8, u8, u8, u8, u8, u8)),
        mk_uuid
    );
    test_round_trip!(array_of_int_roundtrips, Array<Integer>, Vec<i32>);
    test_round_trip!(array_of_bigint_roundtrips, Array<BigInt>, Vec<i64>);
    test_round_trip!(array_of_dynamic_size_roundtrips, Array<Text>, Vec<String>);
    test_round_trip!(
        array_of_nullable_roundtrips,
        Array<Nullable<Text>>,
        Vec<Option<String>>
    );
    test_round_trip!(
        macaddr_roundtrips,
        MacAddr,
        (u8, u8, u8, u8, u8, u8),
        mk_macaddr
    );
    test_round_trip!(
        macaddr8_roundtrips,
        MacAddr8,
        (u8, u8, u8, u8, u8, u8, u8, u8),
        mk_macaddr
    );
    test_round_trip!(cidr_v4_roundtrips, Cidr, (u8, u8, u8, u8), mk_ipv4);
    test_round_trip!(
        cidr_v4_roundtrips_ipnet,
        Cidr,
        (u8, u8, u8, u8),
        mk_ipv4_ipnet
    );
    test_round_trip!(
        cidr_v6_roundtrips,
        Cidr,
        (u16, u16, u16, u16, u16, u16, u16, u16),
        mk_ipv6
    );
    test_round_trip!(
        cidr_v6_roundtrips_ipnet,
        Cidr,
        (u16, u16, u16, u16, u16, u16, u16, u16),
        mk_ipv6_ipnet
    );
    test_round_trip!(inet_v4_roundtrips, Inet, (u8, u8, u8, u8), mk_ipv4);
    test_round_trip!(
        inet_v4_roundtrips_ipnet,
        Inet,
        (u8, u8, u8, u8),

Review comment (suggestion):
This `mk_macaddr` is a function below in this file. We need to have a `mk_macaddr8` variant there as well.

Code after:
    );
    test_round_trip!(
        uuid_roundtrips,
        Uuid,
        (u32, u16, u16, (u8, u8, u8, u8, u8, u8, u8, u8)),
        mk_uuid
    );
    test_round_trip!(array_of_int_roundtrips, Array<Integer>, Vec<i32>);
    test_round_trip!(array_of_bigint_roundtrips, Array<BigInt>, Vec<i64>);
    test_round_trip!(array_of_dynamic_size_roundtrips, Array<Text>, Vec<String>);
    test_round_trip!(
        array_of_nullable_roundtrips,
        Array<Nullable<Text>>,
        Vec<Option<String>>
    );
    test_round_trip!(
        macaddr_roundtrips,
        MacAddr,
        (u8, u8, u8, u8, u8, u8),
        mk_macaddr
    );
    test_round_trip!(
        macaddr8_roundtrips,
        MacAddr8,
        (u8, u8, u8, u8, u8, u8, u8, u8),
        mk_macaddr8
    );
    test_round_trip!(cidr_v4_roundtrips, Cidr, (u8, u8, u8, u8), mk_ipv4);
    test_round_trip!(
        cidr_v4_roundtrips_ipnet,
        Cidr,
        (u8, u8, u8, u8),
        mk_ipv4_ipnet
    );
    test_round_trip!(
        cidr_v6_roundtrips,
        Cidr,
        (u16, u16, u16, u16, u16, u16, u16, u16),
        mk_ipv6
    );
    test_round_trip!(
        cidr_v6_roundtrips_ipnet,
        Cidr,
        (u16, u16, u16, u16, u16, u16, u16, u16),
        mk_ipv6_ipnet
    );
    test_round_trip!(inet_v4_roundtrips, Inet, (u8, u8, u8, u8), mk_ipv4);
    test_round_trip!(
        inet_v4_roundtrips_ipnet,
        Inet,
        (u8, u8, u8, u8),
Repository: diesel-rs/diesel
File: diesel/src/pg/expression/functions.rs (Rust)

Code before:
    ///
    /// let expected: Value = serde_json::json!({});
    /// let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>(
    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
    ///         expected
    /// )).get_result(connection)?;
    /// assert_eq!(record, ("John".to_string(), 30));
    ///
    /// let expected: Value = serde_json::json!({
    ///     "f2": 42,
    /// });
    /// let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>(
    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
    ///         expected
    /// )).get_result(connection)?;
    /// assert_eq!(record, ("John".to_string(), 42));
    ///
    /// #    Ok(())
    /// # }
    /// ```
    #[sql_name = "jsonb_populate_record"]
    fn jsonb_populate_record<
        B: RecordOrNullableRecord + SingleValue,
        J: JsonbOrNullableJsonb + CombinedNullableValue<Jsonb, B>
    >(base: B, from_json: J) -> J::Out;
}


Review comment (refactor):
I've played a bit around on the postgresql command line and it seems like the output type of this function is only null if **both** inputs are null. The `CombineNullableValue` helper trait expresses a constraint that says "if one of the inputs is null the output is null", so that's slightly different. We need to have a similar trait, but with slightly different bounds. Essentially we need a new trait with the same structure, but that replace the usage of `OneIsNullable` in the bounds with [`AllIsNullable`](https://github.com/diesel-rs/diesel/blob/master/diesel/src/sql_types/mod.rs#L690). The trait implementation of `CombineNullableValue` is here: https://github.com/diesel-rs/diesel/blob/a5f7548d4ec979fd144075bd8297687c899cc769/diesel/src/pg/expression/expression_methods.rs#L3698-L3707, that can be just copied + adjusted for the new trait.


Code after:
    /// assert_eq!(record, ("Alice".to_string(), 16));
    ///
    /// let expected: Value = serde_json::json!({});
    /// let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>(
    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
    ///         expected
    /// )).get_result(connection)?;
    /// assert_eq!(record, ("John".to_string(), 30));
    ///
    /// let expected: Value = serde_json::json!({
    ///     "f2": 42,
    /// });
    /// let record: (String, i32) = diesel::select(jsonb_populate_record::<Record<(Text, Integer)>, Jsonb, _, _>(
    ///         sql::<Record<(Text, Integer)>>("ROW('John', 30)"),
    ///         expected
    /// )).get_result(connection)?;
    /// assert_eq!(record, ("John".to_string(), 42));
    ///
    /// #    Ok(())
    /// # }
    /// ```
    #[sql_name = "jsonb_populate_record"]
    fn jsonb_populate_record<
        B: RecordOrNullableRecord + SingleValue,
        J: JsonbOrNullableJsonb + CombinedAllNullableValue<Jsonb, B>
    >(base: B, from_json: J) -> J::Out;
}
Repository: diesel-rs/diesel
File: diesel/src/query_builder/debug_query.rs (Rust)

Code before:
        Ok(query_builder.finish())
    }

    pub(crate) fn binds(&self) -> DebugBinds::<'_, T, DB>
    where
        DB: Backend + Default,
        DB::QueryBuilder: Default,
        T: QueryFragment<DB>,
    {
        DebugBinds::<_, DB>::new(self.query)
    }
}

impl<T, DB> Display for DebugQuery<'_, T, DB>
where
    DB: Backend + Default,
    DB::QueryBuilder: Default,
    T: QueryFragment<DB>,
{
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        // This is not using the `?` operator to reduce the code size of this
        // function, which is getting copies a lot due to monomorphization.
        let query = match self.query() {
            Ok(query) => query,
            Err(err) => return Err(err),
        };

        let debug_binds = self.binds();
        write!(f, "{} -- binds: {:?}", query, debug_binds)
    }
}

impl<T, DB> Debug for DebugQuery<'_, T, DB>
where
    DB: Backend + Default,
    DB::QueryBuilder: Default,
    T: QueryFragment<DB>,
{
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        // This is not using the `?` operator to reduce the code size of this
        // function, which is getting copies a lot due to monomorphization.
        let query = match self.query() {
            Ok(query) => query,
            Err(err) => return Err(err),
        };

        let debug_binds = self.binds();
        f.debug_struct("Query")
            .field("sql", &query)
            .field("binds", &debug_binds)
            .finish()

Review comment (suggestion):
I tried to use a `tri!()` macro instead (see https://github.com/serde-rs/serde/blob/v1.0.217/serde/src/lib.rs#L290-L301), but that slightly bumped the numbers upwards again, so I'm not sure whether it's worth it for the readability benefit.

Code after:
    DB::QueryBuilder: Default,
{
    let debug_binds = DebugBinds::<DB>::new(query);
    let query = serialize_query(query)?;
    write!(f, "{} -- binds: {:?}", query, debug_binds)
}

fn debug<DB>(query: &dyn QueryFragment<DB>, f: &mut fmt::Formatter<'_>) -> fmt::Result
where
    DB: Backend + Default,
    DB::QueryBuilder: Default,
{
    let debug_binds = DebugBinds::<DB>::new(query);
    let query = serialize_query(query)?;
    f.debug_struct("Query")
        .field("sql", &query)
        .field("binds", &debug_binds)
        .finish()
}

impl<T, DB> Display for DebugQuery<'_, T, DB>
where
    DB: Backend + Default,
    DB::QueryBuilder: Default,
    T: QueryFragment<DB>,
{
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        display(self.query, f)
    }
}

impl<T, DB> Debug for DebugQuery<'_, T, DB>
where
    DB: Backend + Default,
    DB::QueryBuilder: Default,
    T: QueryFragment<DB>,
{
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        debug(self.query, f)
    }
}

/// A struct that implements `fmt::Debug` by walking the given AST and writing
/// the `fmt::Debug` implementation of each bind parameter.
pub(crate) struct DebugBinds<'a, DB> {
    query: &'a dyn QueryFragment<DB>,
}

impl<'a, DB> DebugBinds<'a, DB>
where
    DB: Backend,
Repository: diesel-rs/diesel
File: diesel/src/sqlite/expression/functions.rs (Rust)

Code before:
    ///
    /// let version = diesel::select(sql::<Text>("sqlite_version();"))
    ///         .get_result::<String>(connection)?;
    ///
    /// // Querying SQLite version should not fail.
    /// let version_components: Vec<&str> = version.split('.').collect();
    /// let major: u32 = version_components[0].parse().unwrap();
    /// let minor: u32 = version_components[1].parse().unwrap();
    /// let patch: u32 = version_components[2].parse().unwrap();
    ///
    /// if major > 3 || (major == 3 && minor >= 46) {
    ///     /* Valid sqlite version, do nothing */
    /// } else {
    ///     println!("SQLite version is too old, skipping the test.");
    ///     return Ok(());
    /// }
    ///
    /// let result = diesel::select(json_valid::<Json>(json!({"x":35})))
    ///     .get_result::<Integer>(connection)?;
    ///
    /// assert_eq!(1, result);
    ///
    /// # }
    /// ```
    #[sql_name = "json_valid"]
    fn json_valid<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + MaybeNullableValue<Text>>(j: J) -> Integer;
}


Review comment (suggestion):
```suggestion
    fn json_valid<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + MaybeNullableValue<Bool>>(j: J) -> J::Out;
```

Diesel maps such flag integers to a boolean for sqlite so we use `Bool` as return type. That would usually be `-> Bool`. For this particular function sqlite returns `NULL` if a null value is passed in, which means we want to return `Nullable<Bool>` if the input value is nullable and `Bool` otherwise. The `MaybeNullableValue<Bool>` part takes care of that by transforming the generic parameter into the right variant. That variant then can be accessed via the `Out` associated type.



Code after:
    ///
    /// // Querying SQLite version should not fail.
    /// let version_components: Vec<&str> = version.split('.').collect();
    /// let major: u32 = version_components[0].parse().unwrap();
    /// let minor: u32 = version_components[1].parse().unwrap();
    /// let patch: u32 = version_components[2].parse().unwrap();
    ///
    /// if major > 3 || (major == 3 && minor >= 46) {
    ///     /* Valid sqlite version, do nothing */
    /// } else {
    ///     println!("SQLite version is too old, skipping the test.");
    ///     return Ok(());
    /// }
    ///
    /// let result = diesel::select(json_valid::<Json, _>(json!({"x":35})))
    ///     .get_result::<bool>(connection)?;
    ///
    /// assert_eq!(true, result);
    ///
    /// let result = diesel::select(json_valid::<Nullable<Json>, _>(None::<serde_json::Value>))
    ///     .get_result::<Option<bool>>(connection)?;
    ///
    /// assert_eq!(None, result);
    ///
    /// # Ok(())
    /// # }
    /// ```
    #[sql_name = "json_valid"]
    #[cfg(feature = "sqlite")]
    fn json_valid<J: JsonOrNullableJson + MaybeNullableValue<Bool>>(j: J) -> J::Out;
}
Repository: diesel-rs/diesel
File: diesel/src/sqlite/expression/functions.rs (Rust)

Code before:
    /// #
    /// # #[cfg(feature = "serde_json")]
    /// # fn run_test() -> QueryResult<()> {
    /// #     use diesel::dsl::{sql, json_pretty_with_indentation};
    /// #     use serde_json::{json, Value};
    /// #     use diesel::sql_types::{Text, Json, Jsonb, Nullable};
    /// #     let connection = &mut establish_connection();
    ///
    /// let version = diesel::select(sql::<Text>("sqlite_version();"))
    ///         .get_result::<String>(connection)?;
    ///
    /// // Querying SQLite version should not fail.
    /// let version_components: Vec<&str> = version.split('.').collect();
    /// let major: u32 = version_components[0].parse().unwrap();
    /// let minor: u32 = version_components[1].parse().unwrap();
    /// let patch: u32 = version_components[2].parse().unwrap();
    ///
    /// if major > 3 || (major == 3 && minor >= 46) {
    ///     /* Valid sqlite version, do nothing */
    /// } else {
    ///     println!("SQLite version is too old, skipping the test.");
    ///     return Ok(());
    /// }
    ///
    /// let result = diesel::select(json_valid::<Json>(json!({"x":35})))
    ///     .get_result::<Integer>(connection)?;
    ///
    /// assert_eq!(1, result);
    ///
    /// # }
    /// ```
    #[sql_name = "json_valid"]
    fn json_valid<J: JsonOrNullableJsonOrJsonbOrNullableJsonb + MaybeNullableValue<Text>>(j: J) -> Integer;
}


Review comment (suggestion):
```suggestion
    ///     .get_result::<bool>(connection)?;
```

Code after:
    /// #     use diesel::dsl::{sql, json_valid};
    /// #     use serde_json::{json, Value};
    /// #     use diesel::sql_types::{Text, Json, Jsonb, Nullable};
    /// #     let connection = &mut establish_connection();
    ///
    /// let version = diesel::select(sql::<Text>("sqlite_version();"))
    ///         .get_result::<String>(connection)?;
    ///
    /// // Querying SQLite version should not fail.
    /// let version_components: Vec<&str> = version.split('.').collect();
    /// let major: u32 = version_components[0].parse().unwrap();
    /// let minor: u32 = version_components[1].parse().unwrap();
    /// let patch: u32 = version_components[2].parse().unwrap();
    ///
    /// if major > 3 || (major == 3 && minor >= 46) {
    ///     /* Valid sqlite version, do nothing */
    /// } else {
    ///     println!("SQLite version is too old, skipping the test.");
    ///     return Ok(());
    /// }
    ///
    /// let result = diesel::select(json_valid::<Json, _>(json!({"x":35})))
    ///     .get_result::<bool>(connection)?;
    ///
    /// assert_eq!(true, result);
    ///
    /// let result = diesel::select(json_valid::<Nullable<Json>, _>(None::<serde_json::Value>))
    ///     .get_result::<Option<bool>>(connection)?;
    ///
    /// assert_eq!(None, result);
    ///
    /// # Ok(())
    /// # }
    /// ```
    #[sql_name = "json_valid"]
    #[cfg(feature = "sqlite")]
    fn json_valid<J: JsonOrNullableJson + MaybeNullableValue<Bool>>(j: J) -> J::Out;
}
Repository: diesel-rs/diesel
File: diesel/src/sqlite/expression/helper_types.rs (Rust)

Code before:

/// Return type of [`json(json)`](super::functions::json())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json<E> = super::functions::json<SqlTypeOf<E>, E>;

/// Return type of [`jsonb(json)`](super::functions::jsonb())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type jsonb<E> = super::functions::jsonb<SqlTypeOf<E>, E>;

/// Return type of [`json_pretty(json)`](super::functions::json_pretty())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json_pretty<E> = super::functions::json_pretty<SqlTypeOf<E>, E>;

/// Return type of [`json_pretty(json, indent)`](super::functions::json_pretty_with_indentation())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json_pretty_with_indentation<J, I> =
    super::functions::json_pretty_with_indentation<SqlTypeOf<J>, J, I>;

/// Return type of [`json_valid(json)`](super::functions::json_valid())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json_valid<E> = super::functions::json_valid<SqlTypeOf<E>, Integer>;


Review comment (refactor):
```suggestion
pub type json_valid<E> = super::functions::json_valid<SqlTypeOf<E>, E>;
```

That needs to be just `E` and not `Integer` as the helper type accepts one generic argument for the SQL type (the `SqlTypeOf<E>` part) and one generic argument for the expression itself (the `E`))

(That also means removing the `use crate::sql_types::Integer;` line again)

Code after:
/// Return type of [`json(json)`](super::functions::json())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json<E> = super::functions::json<SqlTypeOf<E>, E>;

/// Return type of [`jsonb(json)`](super::functions::jsonb())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type jsonb<E> = super::functions::jsonb<SqlTypeOf<E>, E>;

/// Return type of [`json_pretty(json)`](super::functions::json_pretty())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json_pretty<E> = super::functions::json_pretty<SqlTypeOf<E>, E>;

/// Return type of [`json_pretty(json, indent)`](super::functions::json_pretty_with_indentation())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json_pretty_with_indentation<J, I> =
    super::functions::json_pretty_with_indentation<SqlTypeOf<J>, J, I>;

/// Return type of [`json_valid(json)`](super::functions::json_valid())
#[allow(non_camel_case_types)]
#[cfg(feature = "sqlite")]
pub type json_valid<E> = super::functions::json_valid<SqlTypeOf<E>, E>;