Polymorphic field support could be better
a3kov opened this issue · comments
Thanks for your library.
For polymorphic relationships I am comparing it to polymorphic_embed with Ecto.
Nestru seems lacking because it needs explicit type hint. Consider JSON case: there are no type hints usually, but nested types could have different sets of fields, so it should be possible to match on the fields, which is what polymorphic_embed is capable of, but Nestru isn't.
Hey @a3kov, sorry for the long answer.
The idea of Nestru is to define types explicitly. Here's an example from Readme on how you can keep fields type information in JSON for inspiration: https://github.com/IvanRublev/Nestru#serializing-type-dependent-fields
Yeah, but if that JSON comes from a 3rd party (such as API response case), you can't ask them to provide the type hints.
Ok. I value Nestru to be on the current level of abstraction. So you might write the type selection logic as needed.
No one tool can be suitable for all the problems. I believe you can find what is for yours 🙂