diff --git a/cli/src/generator/models/mod.rs b/cli/src/generator/models/mod.rs index 05e77419..c2189bf1 100644 --- a/cli/src/generator/models/mod.rs +++ b/cli/src/generator/models/mod.rs @@ -596,10 +596,7 @@ pub fn generate(args: &GenerateArgs, module_path: TokenStream) -> Vec ( #field_string, - #pcr::SerializedWhereValue::Object(vec![( - "equals".to_string(), - #pcr::PrismaValue::Null - )]) + #pcr::SerializedWhereValue::Value(#pcr::PrismaValue::Null) ) }, ); @@ -648,7 +645,7 @@ pub fn generate(args: &GenerateArgs, module_path: TokenStream) -> Vec ( #field_string, - #pcr::SerializedWhereValue::Object(vec![("equals".to_string(), #type_as_prisma_value)]) + #pcr::SerializedWhereValue::Value(#type_as_prisma_value) ) } ); diff --git a/integration-tests/tests/find_many.rs b/integration-tests/tests/find_many.rs index 92c674fa..f14eca6a 100644 --- a/integration-tests/tests/find_many.rs +++ b/integration-tests/tests/find_many.rs @@ -264,6 +264,15 @@ async fn filtering_one_to_one_relation() -> TestResult { assert_eq!(users.len(), 1); assert_eq!(users[0].name, "Jamie"); + let users = client + .user() + .find_many(vec![user::profile::is_null()]) + .exec() + .await?; + dbg!(&users); + assert_eq!(users.len(), 1); + assert_eq!(users[0].name, "Jamie"); + cleanup(client).await } diff --git a/src/queries/mod.rs b/src/queries/mod.rs index d96d11b6..bd5e8e2e 100644 --- a/src/queries/mod.rs +++ b/src/queries/mod.rs @@ -96,6 +96,7 @@ impl ModelActionType { pub enum SerializedWhereValue { Object(Vec<(String, prisma_models::PrismaValue)>), List(Vec), + Value(prisma_models::PrismaValue), } impl Into for SerializedWhereValue { @@ -103,6 +104,7 @@ impl Into for SerializedWhereValue { match self { Self::Object(v) => prisma_models::PrismaValue::Object(v), Self::List(v) => prisma_models::PrismaValue::List(v), + Self::Value(v) => v, } } } @@ -138,6 +140,7 @@ impl SerializedWhereInput { None => prisma_models::PrismaValue::Object(params), }, SerializedWhereValue::List(values) => prisma_models::PrismaValue::List(values), + SerializedWhereValue::Value(v) => v, }, ) }