New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support union types and maybe other corner cases #62
Comments
There's a lot to unpack here.
That's indeed not correct, though I don't think your patch is a good solution.
This part looks correct to me.
I agree it's not a bad idea to support this, though I'm also not immediately sure of the best way to support this. |
This has been fixed in e26c57a (and follow-up bc8d79a).
This has been fixed in be6359b (I forgot to credit you, sorry about that). I'll leave this issue open for your last point, though I'm not sure right now if and how that can be fixed. |
Hi @oxan, Thank you for taking the time to respond and fix that bugs!!! I very much appreciate it. And, my apologies for putting so much stuff in a single issue; these were unrelated things. Regarding the last point, we can leave this as it is. If we reencounter this problem, we'll try to solve it ourselves and then post some proposal here. And no worries about the credit; not needed at all, we are happy just helping a bit. |
Hello there!
We have a type alias that makes use of unions, and we would like to map it to a JSONField. This example summarizes the use case (simplified):
The current implementation does not support dynamically mapping fields of type
Json
to a JSONField. Note that this problem does not exist when declaring the Serializer as you can declare theconfig
field as a JSONField. This problem affects only dynamic fields.The following two patches made it work. I think the first one is a bug as it detects wrongly
int | str | None
as anOptional[int]
.The second patch allows mapping UnionType aliases to Field serializers but does not support overriding other kinds of aliases. For instance, it does not allow mapping JsonKV to a JSONField:
In this case, the library calls
lookup_type_in_mapping
using JsonPrimitive rather than JsonKV. To be honest, I don't know which is the best approach to solve this or even if this should be supported. It makes sense for our dynamic serializers though.The text was updated successfully, but these errors were encountered: