Skip to content

Commit

Permalink
fix specta include/select
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed May 9, 2024
1 parent b6cdcdb commit ba8a6ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 757 deletions.
2 changes: 1 addition & 1 deletion crates/generator-macros/src/partial_unchecked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn proc_macro(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let specta_attrs = cfg!(feature = "specta").then(|| {
quote! {
#[derive(::prisma_client_rust::specta::Type)]
#[specta(crate = "prisma_client_rust::specta")]
#[specta(crate = prisma_client_rust::specta)]
}
});

Expand Down
15 changes: 8 additions & 7 deletions crates/generator-macros/src/select_include/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn definitions(input: &Input) -> TokenStream {
if cfg!(feature = "specta") {
attrs.extend(quote! {
#[derive(::prisma_client_rust::specta::Type)]
#[specta(crate = "prisma_client_rust::specta")]
#[specta(crate = prisma_client_rust::specta)]
});

attrs.extend(match &macro_rules.name {
Expand Down Expand Up @@ -62,9 +62,10 @@ pub fn definitions(input: &Input) -> TokenStream {
let (field_type, field_module) = field_in_selectables
.zip(field_in_selection.and_then(|f| f.sub_selection.as_ref()))
.and_then(|(field_in_selectables, (variant, sub_selection))| {
let Arity::Relation(relation_model_path, arity) = &field_in_selectables.arity else {
return None;
};
let Arity::Relation(relation_model_path, arity) = &field_in_selectables.arity
else {
return None;
};

let value = quote! {
pub mod #ident {
Expand All @@ -77,9 +78,9 @@ pub fn definitions(input: &Input) -> TokenStream {
let base = quote!(#ident::Data);

let typ = match arity {
RelationArity::One => base,
RelationArity::Many => quote!(Vec<#base>),
RelationArity::Optional => quote!(Option<#base>),
RelationArity::One => base,
RelationArity::Many => quote!(Vec<#base>),
RelationArity::Optional => quote!(Option<#base>),
};

Some((typ, Some(value)))
Expand Down
Loading

0 comments on commit ba8a6ab

Please sign in to comment.