You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FromJsonQueryResult currently doesn't work with generics. This is useful to e. g. wrap a Vec<T> in a custom type List<T>(Vec<T>) that implements the required traits to be used in SeaORM.
replace all occurances of impl with impl #generics where #generics comes from the parsed macro input
replace all occurances of #ident with #ident_with_generics where #ident_with_generics is the ident followed by the generic paramters with their trait bounds removed
add trait bounds where #ident_with_generics: Serialize and where #ident_with_generics: DeserializeOwned where required (see workaround below)
Steps to Reproduce
cargo new test-project
cd test-project
cargo add sea-orm
cargo add serde -F derive
cargo add serde_json
Paste this code into src/main.rs
use sea_orm::{prelude::*,FromJsonQueryResult};use serde::{Deserialize,Serialize};[derive(Clone,Debug,Default,PartialEq,Deserialize,Serialize,FromJsonQueryResult)]#[serde(transparent)]pubstructList<T>(pubVec<T>);
Description
FromJsonQueryResult
currently doesn't work with generics. This is useful to e. g. wrap aVec<T>
in a custom typeList<T>(Vec<T>)
that implements the required traits to be used in SeaORM.This is caused by the
FromJsonQueryResult
currently ignoring any generics.This can be fixed with these changes to
expand_derive_from_json_query_result
andderive_from_json_query_result
:impl
withimpl #generics
where#generics
comes from the parsed macro input#ident
with#ident_with_generics
where#ident_with_generics
is theident
followed by the generic paramters with their trait bounds removedwhere #ident_with_generics: Serialize
andwhere #ident_with_generics: DeserializeOwned
where required (see workaround below)Steps to Reproduce
cargo new test-project
cd test-project
cargo add sea-orm
cargo add serde -F derive
cargo add serde_json
src/main.rs
Expected Behavior
compiles without errors
Actual Behavior
Reproduces How Often
Is it always reproducible? -> Yes
Workarounds
manually implement the derived traits:
Reproducible Example
Versions
The text was updated successfully, but these errors were encountered: