-
Notifications
You must be signed in to change notification settings - Fork 20
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
ULID can't be serialized with Pydantic's dump model to json #20
Comments
A bypass to this problem is to build your own class MyModel(BaseModel):
my_id: ULID
@field_serializer("my_id", return_type="str", when_used="unless-none")
@staticmethod
def serialize_ulid(ulid: ULID) -> str:
return str(ulid) Then, the code above would work. But I would want support from this library so I wouldn't need to copy-paste it. |
Opened a PR to solve this issue: #21 |
Sorry but this is a major defect. You will get a ton of extra users by having Pydantic support, so serialization should be supported. I just lost an hour because I suspected I did something wrong in my dependencies. Than finding out that this basic feature is not supported is disappointing. |
This should be fixed in version |
Hello,
I see this package has support for
Pydantic
. I want to use themodel_dump_json
so I could serialize my model to json in my webserver. But I can't serialize ULID. It seems like an implementation error.How to reproduce:
Pip freeze:
Code:
The output would be:
We can see ha model dump is supported, but not model dump json.
The text was updated successfully, but these errors were encountered: