Skip to content

Commit

Permalink
fix the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Le Roux committed Sep 30, 2024
1 parent fd10228 commit 1e9ba1a
Show file tree
Hide file tree
Showing 5 changed files with 425 additions and 352 deletions.
12 changes: 10 additions & 2 deletions diesel/src/pg/expression/expression_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3418,9 +3418,11 @@ where

pub(in crate::pg) mod private {
use crate::sql_types::{
Array, Binary, Cidr, Inet, Integer, Json, Jsonb, MaybeNullableType, Multirange, Nullable,
OneIsNullable, Range, SingleValue, SqlType, Text,
Array, Binary, Cidr, Inet, Integer, MaybeNullableType, Multirange, Nullable, OneIsNullable,
Range, SingleValue, SqlType, Text,
};
#[cfg(feature = "serde_json")]
use crate::sql_types::{Json, Jsonb};
use crate::{Expression, IntoSql};

/// Marker trait used to implement `ArrayExpressionMethods` on the appropriate
Expand Down Expand Up @@ -3558,7 +3560,9 @@ pub(in crate::pg) mod private {
)]
pub trait JsonOrNullableJson {}

#[cfg(feature = "serde_json")]
impl JsonOrNullableJson for Json {}
#[cfg(feature = "serde_json")]
impl JsonOrNullableJson for Nullable<Json> {}

/// A trait that describes valid json indices used by postgresql
Expand Down Expand Up @@ -3646,9 +3650,13 @@ pub(in crate::pg) mod private {
note = "try to provide an expression that produces one of the expected sql types"
)]
pub trait JsonOrNullableJsonOrJsonbOrNullableJsonb {}
#[cfg(feature = "serde_json")]
impl JsonOrNullableJsonOrJsonbOrNullableJsonb for Json {}
#[cfg(feature = "serde_json")]
impl JsonOrNullableJsonOrJsonbOrNullableJsonb for Nullable<Json> {}
#[cfg(feature = "serde_json")]
impl JsonOrNullableJsonOrJsonbOrNullableJsonb for Jsonb {}
#[cfg(feature = "serde_json")]
impl JsonOrNullableJsonOrJsonbOrNullableJsonb for Nullable<Jsonb> {}

pub trait JsonIndex {
Expand Down
1 change: 1 addition & 0 deletions diesel/src/pg/types/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl ToSql<sql_types::Jsonb, Pg> for serde_json::Value {
}

#[cfg(test)]
#[cfg(all(feature = "postgres", feature = "serde_json"))]
mod tests {
use crate::deserialize::FromSql;
use crate::pg::{Pg, PgValue};
Expand Down
31 changes: 20 additions & 11 deletions diesel/src/sql_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ pub struct Timestamp;
#[cfg(any(
feature = "postgres_backend",
feature = "mysql_backend",
all(feature = "sqlite", feature = "serde_json")
all(feature = "sqlite", feature = "serde_json",)
))]
#[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
#[diesel(postgres_type(oid = 114, array_oid = 199))]
Expand Down Expand Up @@ -479,21 +479,24 @@ pub struct Json;
/// }
/// }
///
/// # #[cfg(all(
/// # feature = "serde_json",
/// # any(
/// # feature = "postgres_backend",
/// # all(feature = "sqlite", feature = "returning_clauses_for_sqlite_3_35"),
/// # )
/// # ))]
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # use diesel::insert_into;
/// # use self::contacts::dsl::*;
/// # let connection = &mut connection_no_data();
/// # #[cfg(all(feature = "postgres_backend", feature = "serde_json"))]
/// # #[cfg(feature = "postgres_backend")]
/// # diesel::sql_query("CREATE TABLE contacts (
/// # id SERIAL PRIMARY KEY,
/// # name VARCHAR NOT NULL,
/// # address JSONB NOT NULL
/// # )").execute(connection)?;
/// # #[cfg(all(
/// # feature = "sqlite",
/// # feature = "serde_json",
/// # feature = "returning_clauses_for_sqlite_3_35"
/// # ))]
/// # #[cfg(feature = "sqlite")]
/// # diesel::sql_query("CREATE TABLE contacts (
/// # id INT PRIMARY KEY,
/// # name TEXT NOT NULL,
Expand All @@ -512,12 +515,18 @@ pub struct Json;
/// assert_eq!(santas_address, inserted_address);
/// # Ok(())
/// # }
/// # #[cfg(not(feature = "serde_json"))]
/// # #[cfg(not(all(
/// # feature = "serde_json",
/// # any(
/// # feature = "postgres_backend",
/// # all(feature = "sqlite", feature = "returning_clauses_for_sqlite_3_35"),
/// # )
/// # )))]
/// # fn main() {}
/// ```
#[cfg(any(
feature = "postgres_backend",
all(feature = "sqlite", feature = "serde_json")
#[cfg(all(
feature = "serde_json",
any(feature = "postgres_backend", feature = "sqlite")
))]
#[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
#[diesel(postgres_type(oid = 3802, array_oid = 3807))]
Expand Down
Loading

0 comments on commit 1e9ba1a

Please sign in to comment.