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};
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 toexpand_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
[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize, FromJsonQueryResult)]
[serde(transparent)]
pub struct List(pub Vec);
Reproduces How Often
Is it always reproducible? -> Yes
Workarounds
manually implement the derived traits:
Reproducible Example
Versions