Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix generated JsonFilter type mismatch #470

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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