Skip to content

Commit

Permalink
factorize the Jsonb SQLite/Pg example
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Le Roux committed Sep 27, 2024
1 parent 4dd26d9 commit fd10228
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions diesel/src/sql_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,19 +471,6 @@ pub struct Json;
/// # #![allow(dead_code)]
/// # include!("../doctest_setup.rs");
/// #
/// # #[cfg(all(feature = "postgres_backend", feature = "serde_json"))]
/// table! {
/// contacts {
/// id -> Integer,
/// name -> VarChar,
/// address -> Jsonb,
/// }
/// }
/// # #[cfg(all(
/// # feature = "sqlite",
/// # feature = "serde_json",
/// # feature = "returning_clauses_for_sqlite_3_35"
/// # ))]
/// table! {
/// contacts {
/// id -> Integer,
Expand All @@ -492,11 +479,11 @@ pub struct Json;
/// }
/// }
///
/// # #[cfg(all(feature = "postgres_backend", feature = "serde_json"))]
/// # 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"))]
/// # diesel::sql_query("CREATE TABLE contacts (
/// # id SERIAL PRIMARY KEY,
/// # name VARCHAR NOT NULL,
Expand All @@ -507,13 +494,11 @@ pub struct Json;
/// # feature = "serde_json",
/// # feature = "returning_clauses_for_sqlite_3_35"
/// # ))]
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # use diesel::insert_into;
/// # use diesel::query_dsl::RunQueryDsl;
/// # use diesel::test_helpers::connection;
/// # use diesel::ExpressionMethods;
/// # use diesel::dsl::*;
/// # let connection = &mut connection();
/// # diesel::sql_query("CREATE TABLE contacts (
/// # id INT PRIMARY KEY,
/// # name TEXT NOT NULL,
/// # address BLOB NOT NULL
/// # )").execute(connection)?;
/// let santas_address: serde_json::Value = serde_json::from_str(r#"{
/// "street": "Article Circle Expressway 1",
/// "city": "North Pole",
Expand Down

0 comments on commit fd10228

Please sign in to comment.