-
Notifications
You must be signed in to change notification settings - Fork 217
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
[BUG] Error when saving Documents with Fields of type date #736
Comments
The Dictionary |
Hi, |
Is this the suggested way to store dates in MongoDB? AFAICT there's no dedicated |
Hi @QSHolzner , |
Hi @roman-right, But if beanie is used "out of the box", then the use of |
Hi @QSHolzner , |
Agreed; for me this whole section that calls |
Hi, @gsakkis. Would you mind to pick this one up? |
Hi @roman-right, you mean the removal of the code I linked to? |
@gsakkis this part or the entire problem with the |
My understanding based on the discussion above was that Beanie should not include an encoder for |
I don't have strong opinion about this specific type. I mean, we can have a default representation for sure. The most important thing here is that the exception is not very intuitive. If not incorrect even. |
Describe the bug
If the type of a field is
date
and notdatetime
, then the following error occurs when saving:To Reproduce
If the type of start_date is changed to
datetime.datetime
it works.Expected behavior
A Field of type date should be saved in the db as datetime.
Additional context
The dictionary ENCODERS_BY_TYPE contains special conditions for certain types.
Would it be possible to include the type date here?
In PyMongo only the type datetime is accepted, so it makes sense to convert the date fields in the model to datetime so that they can be written to the DB.
Here is an example of how I extend the dictionry with the special treatment for this type. It would be nice if this is provided by default.
The text was updated successfully, but these errors were encountered: