-
-
Notifications
You must be signed in to change notification settings - Fork 754
✨ Add support for pydantic date types #1384
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
base: main
Are you sure you want to change the base?
✨ Add support for pydantic date types #1384
Conversation
@dereisele, thanks for your efforts! I think this should be covered by tests. Would you like to work on this? |
Thank you for providing this library in the first place. Sure, can you show me a similar test? |
As I see it, we need to create a model with different field types that are affected by this PR and test that generate |
@@ -688,6 +701,15 @@ def get_sqlalchemy_type(field: Any) -> Any: | |||
return Interval | |||
if issubclass(type_, time): | |||
return Time | |||
if IS_PYDANTIC_V2: | |||
if issubclass(type_, (FutureDate, PastDate)): | |||
return DateTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this. Why not Date
?
from pydantic import ( | ||
BaseModel, | ||
EmailStr, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put unrelated reformatting in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need this particular reformatting at all)
Add support for pydantic date types
This PR adds mappings for the Pydantic Datetime Types. https://docs.pydantic.dev/latest/api/types/#pydantic.types.AwareDatetime
It improves #539.
Please let me know how I add unittests for this.