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 04a9a11
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
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
1 change: 1 addition & 0 deletions diesel/src/sqlite/types/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/sqlite/types/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
7 changes: 6 additions & 1 deletion diesel/src/type_impls/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 04a9a11

Please sign in to comment.