mathieuprog / polymorphic_embed

Polymorphic embeds in Ecto
Apache License 2.0
341 stars 63 forks source link

Hybrid matching strategy #79

Closed a3kov closed 1 year ago

a3kov commented 1 year ago

I am trying to parse Telegram Bot API using Ecto embedded_schemas and polymorphic_embed. The issue with the API is that it's not possible to match embedded type based on a single strategy:

I'm thinking of patching this library to allow "hybrid" matching mode: use 1 strategy, and if it yields more than 1 result, use second strategy on top of matched subtypes to get the final match. I'm willing to submit it as a PR to this project, but first I would need to know if you will accept it, and your feedback on the general direction.

a3kov commented 1 year ago

I've dug a bit deeper in the API, and it seems the types missing a proper "type field" are coming from the client side, so parsing is not needed in most cases. However, if I was to approach such a feature, an interesting option would be something like https://github.com/mathieuprog/polymorphic_embed/pull/18