Skip to content

Commit

Permalink
Merge pull request #470 from hostbee/fix-generator-json
Browse files Browse the repository at this point in the history
fix generated JsonFilter type mismatch
  • Loading branch information
Brendonovich authored Dec 13, 2024
2 parents e269dee + e36bafb commit 11ccf18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions crates/generator/src/read_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub fn generate_module(args: &GenerateArgs) -> TokenStream {

let typ = field.type_tokens(&quote!(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) =>
Expand All @@ -37,9 +37,8 @@ pub fn generate_module(args: &GenerateArgs) -> TokenStream {
)]
)
},
))
} else {
Some((
)),
_ => Some((
quote!(#variant_name(#typ)),
quote! {
Self::#variant_name(#value_ident) =>
Expand All @@ -50,7 +49,7 @@ pub fn generate_module(args: &GenerateArgs) -> TokenStream {
)]
)
},
))
)),
}
})
.unzip();
Expand Down
2 changes: 1 addition & 1 deletion crates/sdk/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
Expand Down

0 comments on commit 11ccf18

Please sign in to comment.