diff --git a/crates/generator/src/read_filters.rs b/crates/generator/src/read_filters.rs index 00abda6..285f1e9 100644 --- a/crates/generator/src/read_filters.rs +++ b/crates/generator/src/read_filters.rs @@ -23,9 +23,9 @@ pub fn generate_module(args: &GenerateArgs) -> TokenStream { let typ = field.type_tokens("e!(super::super::)); - // https://github.com/Brendonovich/prisma-client-rust/issues/297 - if filter.name == "JsonNullable" && field.name == "equals" { - Some(( + match (filter.name.as_str(), field.name.as_str()) { + // https://github.com/Brendonovich/prisma-client-rust/issues/297 + ("JsonNullable", "equals") => Some(( quote!(#variant_name(Option<#typ>)), quote! { Self::#variant_name(#value_ident) => @@ -37,9 +37,8 @@ pub fn generate_module(args: &GenerateArgs) -> TokenStream { )] ) }, - )) - } else { - Some(( + )), + _ => Some(( quote!(#variant_name(#typ)), quote! { Self::#variant_name(#value_ident) => @@ -50,7 +49,7 @@ pub fn generate_module(args: &GenerateArgs) -> TokenStream { )] ) }, - )) + )), } }) .unzip(); diff --git a/crates/sdk/src/extensions.rs b/crates/sdk/src/extensions.rs index 80d9ba6..f73057e 100644 --- a/crates/sdk/src/extensions.rs +++ b/crates/sdk/src/extensions.rs @@ -241,7 +241,7 @@ impl ScalarTypeExt for ScalarType { ScalarType::Decimal => quote!(#v::String(#var.to_string())), ScalarType::Boolean => quote!(#v::Boolean(#var)), ScalarType::String => quote!(#v::String(#var)), - ScalarType::Json => quote!(#v::Json(#pcr::serde_json::to_string(&#var).unwrap())), + ScalarType::Json => quote!(#v::Json(#pcr::serde_json::to_value(&#var).unwrap())), ScalarType::DateTime => quote!(#v::DateTime(#var)), ScalarType::Bytes => quote!(#v::Bytes(#var)), }