From 15617d9d871051a12bb3fdd30ff5535518a36eb2 Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Tue, 25 Jun 2024 15:42:36 +0200 Subject: [PATCH] Case-sensitive enum type casts --- src/query/helper.rs | 4 ++-- src/query/update.rs | 4 ++-- src/tests_cfg/sea_orm_active_enums.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/query/helper.rs b/src/query/helper.rs index a78090759..11fa2bb02 100644 --- a/src/query/helper.rs +++ b/src/query/helper.rs @@ -52,7 +52,7 @@ pub trait QuerySelect: Sized { /// .column(lunch_set::Column::Tea) /// .build(DbBackend::Postgres) /// .to_string(), - /// r#"SELECT CAST("lunch_set"."tea" AS text) FROM "lunch_set""# + /// r#"SELECT CAST("lunch_set"."tea" AS "text") FROM "lunch_set""# /// ); /// assert_eq!( /// lunch_set::Entity::find() @@ -141,7 +141,7 @@ pub trait QuerySelect: Sized { /// .columns([lunch_set::Column::Name, lunch_set::Column::Tea]) /// .build(DbBackend::Postgres) /// .to_string(), - /// r#"SELECT "lunch_set"."name", CAST("lunch_set"."tea" AS text) FROM "lunch_set""# + /// r#"SELECT "lunch_set"."name", CAST("lunch_set"."tea" AS "text") FROM "lunch_set""# /// ); /// assert_eq!( /// lunch_set::Entity::find() diff --git a/src/query/update.rs b/src/query/update.rs index 9863af6fc..c557a2949 100644 --- a/src/query/update.rs +++ b/src/query/update.rs @@ -311,7 +311,7 @@ mod tests { .filter(lunch_set::Column::Tea.eq(Tea::BreakfastTea)) .build(DbBackend::Postgres) .to_string(), - r#"UPDATE "lunch_set" SET "tea" = CAST('EverydayTea' AS tea) WHERE "lunch_set"."tea" = (CAST('BreakfastTea' AS tea))"#, + r#"UPDATE "lunch_set" SET "tea" = CAST('EverydayTea' AS "TeaType") WHERE "lunch_set"."tea" = (CAST('BreakfastTea' AS "TeaType"))"#, ); } @@ -325,7 +325,7 @@ mod tests { }) .build(DbBackend::Postgres) .to_string(), - r#"UPDATE "lunch_set" SET "tea" = CAST('EverydayTea' AS tea) WHERE "lunch_set"."id" = 1"#, + r#"UPDATE "lunch_set" SET "tea" = CAST('EverydayTea' AS "TeaType") WHERE "lunch_set"."id" = 1"#, ); } } diff --git a/src/tests_cfg/sea_orm_active_enums.rs b/src/tests_cfg/sea_orm_active_enums.rs index a5aba5b19..1922492ec 100644 --- a/src/tests_cfg/sea_orm_active_enums.rs +++ b/src/tests_cfg/sea_orm_active_enums.rs @@ -2,7 +2,7 @@ use crate as sea_orm; use crate::entity::prelude::*; #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "tea")] +#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "TeaType")] pub enum Tea { #[sea_orm(string_value = "EverydayTea")] EverydayTea,