From caa85d7fbaaf90f843a14f5cd695c710ee2ca30f Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 19 Aug 2021 18:17:02 +0800 Subject: [PATCH] Try typed mull value SeaQL/sea-query#107 --- Cargo.toml | 2 +- src/entity/base_entity.rs | 4 ++-- src/lib.rs | 2 +- src/query/update.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 58e2c897..bd3bf4f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ futures = { version = "^0.3" } futures-util = { version = "^0.3" } rust_decimal = { version = "^1", optional = true } sea-orm-macros = { version = "^0.1", path = "sea-orm-macros", optional = true } -sea-query = { version = "^0.14", features = ["thread-safe"] } +sea-query = { version = "^0.14", features = ["thread-safe"], git = "https://github.com/SeaQL/sea-query.git", branch = "typed-null-value" } sea-strum = { version = "^0.21", features = ["derive", "sea-orm"] } serde = { version = "^1.0", features = ["derive"] } sqlx = { version = "^0.5", optional = true } diff --git a/src/entity/base_entity.rs b/src/entity/base_entity.rs index e318da40..d0740307 100644 --- a/src/entity/base_entity.rs +++ b/src/entity/base_entity.rs @@ -425,7 +425,7 @@ pub trait EntityTrait: EntityName { /// # let _: Result<(), DbErr> = smol::block_on(async { /// # /// let update_result = fruit::Entity::update_many() - /// .col_expr(fruit::Column::CakeId, Expr::value(Value::Null)) + /// .col_expr(fruit::Column::CakeId, Expr::value(Value::Int(None))) /// .filter(fruit::Column::Name.contains("Apple")) /// .exec(&db) /// .await?; @@ -438,7 +438,7 @@ pub trait EntityTrait: EntityName { /// assert_eq!( /// db.into_transaction_log(), /// vec![Transaction::from_sql_and_values( - /// DbBackend::Postgres, r#"UPDATE "fruit" SET "cake_id" = $1 WHERE "fruit"."name" LIKE $2"#, vec![Value::Null, "%Apple%".into()] + /// DbBackend::Postgres, r#"UPDATE "fruit" SET "cake_id" = $1 WHERE "fruit"."name" LIKE $2"#, vec![Value::Int(None), "%Apple%".into()] /// )]); /// ``` fn update_many() -> UpdateMany { diff --git a/src/lib.rs b/src/lib.rs index 93ec2545..377bd62b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -129,7 +129,7 @@ //! //! // update many: UPDATE "fruit" SET "cake_id" = NULL WHERE "fruit"."name" LIKE '%Apple%' //! Fruit::update_many() -//! .col_expr(fruit::Column::CakeId, Expr::value(Value::Null)) +//! .col_expr(fruit::Column::CakeId, Expr::value(Value::Int(None))) //! .filter(fruit::Column::Name.contains("Apple")) //! .exec(db) //! .await?; diff --git a/src/query/update.rs b/src/query/update.rs index 0c60f472..21fd39cb 100644 --- a/src/query/update.rs +++ b/src/query/update.rs @@ -232,7 +232,7 @@ mod tests { fn update_4() { assert_eq!( Update::many(fruit::Entity) - .col_expr(fruit::Column::CakeId, Expr::value(Value::Null)) + .col_expr(fruit::Column::CakeId, Expr::value(Value::Int(None))) .filter(fruit::Column::Id.eq(2)) .build(DbBackend::Postgres) .to_string(),