This commit is contained in:
Chris Tsang 2023-12-14 19:47:52 +00:00
parent 4ecf47e087
commit b8ad6303d8

View File

@ -111,18 +111,19 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> {
.unwrap() .unwrap()
); );
// Equivalent to the above. // Equivalent to the above.
let select_with_tea_in = Entity::find().filter(Column::Tea.is_in([Tea::EverydayTea])); let select_with_tea_in =
Entity::find().filter(Column::Tea.is_in([Tea::EverydayTea, Tea::BreakfastTea]));
assert_eq!( assert_eq!(
select_with_tea_in select_with_tea_in
.build(sea_orm::DatabaseBackend::Postgres) .build(sea_orm::DatabaseBackend::Postgres)
.to_string(), .to_string(),
[ [
"SELECT \"active_enum\".\"id\",", r#"SELECT "active_enum"."id","#,
"\"active_enum\".\"category\",", r#""active_enum"."category","#,
"\"active_enum\".\"color\",", r#""active_enum"."color","#,
"CAST(\"active_enum\".\"tea\" AS text)", r#"CAST("active_enum"."tea" AS text)"#,
"FROM \"active_enum\"", r#"FROM "public"."active_enum""#,
"WHERE \"active_enum\".\"tea\" IN (CAST('EverydayTea' AS tea))", r#"WHERE "active_enum"."tea" IN (CAST('EverydayTea' AS tea), CAST('BreakfastTea' AS tea))"#,
] ]
.join(" ") .join(" ")
); );
@ -149,13 +150,13 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> {
.build(sea_orm::DatabaseBackend::Postgres) .build(sea_orm::DatabaseBackend::Postgres)
.to_string(), .to_string(),
[ [
"SELECT \"active_enum\".\"id\",", r#"SELECT "active_enum"."id","#,
"\"active_enum\".\"category\",", r#""active_enum"."category","#,
"\"active_enum\".\"color\",", r#""active_enum"."color","#,
"CAST(\"active_enum\".\"tea\" AS text)", r#"CAST("active_enum"."tea" AS text)"#,
"FROM \"active_enum\"", r#"FROM "public"."active_enum""#,
"WHERE \"active_enum\".\"tea\" IS NOT NULL", r#"WHERE "active_enum"."tea" IS NOT NULL"#,
"AND \"active_enum\".\"tea\" NOT IN (CAST('BreakfastTea' AS tea))", r#"AND "active_enum"."tea" NOT IN (CAST('BreakfastTea' AS tea))"#,
] ]
.join(" ") .join(" ")
); );