-
-
Notifications
You must be signed in to change notification settings - Fork 745
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 for MongoDB Decimal type #1045
Comments
Hi, how do you need this feature to be supported? By default or with some schema set-up? Regards, |
@nicolaiarocci should it be a default behavior or should it be a set-up in same places of the schema? This is how to support it: https://api.mongodb.com/python/3.4.0/api/bson/decimal128.html |
@Amedeo91 not quite sure what you mean by 'default or with some schema set-up', but I guess I had pictured it as being done by a A nice extra would be the ability to validate based on the number of decimal places. For example, reject a value with more than 2 decimal places. Of course, this could be done with custom validation rules. |
For the second point, I think it is more a specific need, hence it might be customized by the framework user. For the first point, I was referring that Eve might store every number as decimal type in Mongo or either to specify a new type in the schema. @nicolaiarocci what would you suggest? |
Ok, I just did a small analysis: it would be enough to add the lamda function in the serializers dictionary inside the Mongo class in the file eve\io\mongo\mongo.py |
@Amedeo91 On second thought (see you PR on Cerberus), couldn't you simply update Eve's custom validator instead of updating Cerberus core? It is true that Decimal support out of Eve's scope is nice but, in fact, there have been no requests for that in Cerberus yet. WIth a single Eve PR we could add validation and serialization for Decimals. Thoughts? |
@nicolaiarocci, I was thinking the same thing this morning! :) |
I will try to do the PR this days! :) |
and i didn't dare to propose. :-) |
It's merged to master. |
This is a feature request for support for the newly added MongoDB Decimal type:
https://docs.mongodb.com/master/release-notes/3.4/#decimal-type
I'm sure you've got plenty of things to do, I just wanted to make sure it was on the radar!
Thanks,
Matt
The text was updated successfully, but these errors were encountered: