From 04a9a1129323584628eb2ca6976522a950307fd0 Mon Sep 17 00:00:00 2001 From: Jean-Marc Le Roux Date: Mon, 30 Sep 2024 19:59:19 +0200 Subject: [PATCH] fix the CI --- diesel/src/pg/types/json.rs | 1 + diesel/src/sql_types/mod.rs | 31 ++++++++++++++++++++----------- diesel/src/sqlite/types/json.rs | 1 + diesel/src/sqlite/types/mod.rs | 2 +- diesel/src/type_impls/json.rs | 7 ++++++- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/diesel/src/pg/types/json.rs b/diesel/src/pg/types/json.rs index 9f43addf5e2e..f8603872b308 100644 --- a/diesel/src/pg/types/json.rs +++ b/diesel/src/pg/types/json.rs @@ -47,6 +47,7 @@ impl ToSql for serde_json::Value { } #[cfg(test)] +#[cfg(all(feature = "postgres", feature = "serde_json"))] mod tests { use crate::deserialize::FromSql; use crate::pg::{Pg, PgValue}; diff --git a/diesel/src/sql_types/mod.rs b/diesel/src/sql_types/mod.rs index 31ac664142b7..d581ab1b3e32 100644 --- a/diesel/src/sql_types/mod.rs +++ b/diesel/src/sql_types/mod.rs @@ -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))] @@ -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> { /// # 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, @@ -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))] diff --git a/diesel/src/sqlite/types/json.rs b/diesel/src/sqlite/types/json.rs index 91fe45ee0b7f..a4cfeecef615 100644 --- a/diesel/src/sqlite/types/json.rs +++ b/diesel/src/sqlite/types/json.rs @@ -451,6 +451,7 @@ fn write_jsonb_object( } #[cfg(test)] +#[cfg(feature = "returning_clauses_for_sqlite_3_35")] mod tests { use super::*; use crate::query_dsl::RunQueryDsl; diff --git a/diesel/src/sqlite/types/mod.rs b/diesel/src/sqlite/types/mod.rs index 8f3235c96d0f..1fabfce5aac1 100644 --- a/diesel/src/sqlite/types/mod.rs +++ b/diesel/src/sqlite/types/mod.rs @@ -1,5 +1,5 @@ mod date_and_time; -#[cfg(all(feature = "sqlite", feature = "serde_json"))] +#[cfg(all(feature = "sqlite", feature = "serde_json",))] mod json; mod numeric; diff --git a/diesel/src/type_impls/json.rs b/diesel/src/type_impls/json.rs index 9d19c464fa90..57f2d1bc10e9 100644 --- a/diesel/src/type_impls/json.rs +++ b/diesel/src/type_impls/json.rs @@ -9,5 +9,10 @@ use crate::sql_types::Jsonb; #[derive(AsExpression, FromSqlRow)] #[diesel(foreign_derive)] #[diesel(sql_type = Json)] -#[cfg_attr(any(feature = "postgres_backend", feature = "sqlite"), diesel(sql_type = Jsonb))] +#[cfg_attr( + any( + feature = "postgres_backend", + feature = "sqlite" + ), +diesel(sql_type = Jsonb))] struct SerdeJsonValueProxy(serde_json::Value);