Skip to content
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

fix: Support enums #125

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

fix: Support enums #125

wants to merge 1 commit into from

Conversation

jefersondaniel
Copy link
Owner

@jefersondaniel jefersondaniel commented Jul 6, 2024

I'm sending this PR as a draft because the tests don't pass yet. The JSON mode of pydantic also affects the datetime serialization so it creates a break compatibility.

@@ -70,7 +70,7 @@ def to_document(model: T) -> dict:
:return: dict
"""
model_with_id = cast(ModelWithId, model)
data = model_with_id.model_dump()
data = model_with_id.model_dump(mode="json")
Copy link

@KozyrevIvan KozyrevIvan Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should exclude computed_field here

This can be done for example like this:

computed_fields = set(model.model_computed_fields)
data = model_with_id.model_dump(
    mode="json", 
    exclude=computed_fields,
 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants