Comments (2)
I think your usecase is totally legit so we should add some checks in the __init__
for the missing value:
- Make sure
missing
param provides an iterable or a callable - if iterable, convert it to List :
missing = List(self.container, missing)
- if callable, wrap it :
missing = lambda *args, **kwargs: List(missing(*args, **kwargs))
On top of that we should add a word about this in ListField's documentation
from umongo.
DictField
is also affected.
I pushed a fix for this in #171.
It is along the lines of your proposal above.
The checks are performed after the call to super().__init__
to avoid leaking data_object structures (Dict
and List
) to the pure marshmallow Schema
. And because self.container
is not defined before that.
At this point, I was tempted to call self.deserialize
rather than Dict
or List
, and even to factorize than in Field
itself. I don't think it would hurt. In fact, it would allow the user to pass default values in both serialized form and deserialized form (assuming the field can swallow its deserialized form, which I think is the case as this is the intent of the _deserialize
override in some fields, such as DateTime
). Since this might have other consequences, I left it aside for a moment.
Maybe ReferenceField
should be addressed as well. It is a bit different and I don't really see the use case, so I'm leaving it as is.
from umongo.
Related Issues (20)
- How to reduce time when query doc from mongo with motor driver
- keyPattern not existing in DuplicteKeyError, causing `KeyError` HOT 3
- `find` with `GenericReferenceField` does not return the document.
- pymongo Database class explicitly denies bool HOT 3
- always $set usage with updating from commit
- Date serialization removes microseconds, but not during commit(), only when deserializing from mongo HOT 5
- 'id' based query other than of type ObjectId is returning None HOT 1
- Why does field.UUIDField return the same value for each instance? HOT 4
- Embedded document: unknown "fieldname" field in DB HOT 1
- DictFields and EmbeddedFields aren't created with default values HOT 4
- How to use UUID as _id HOT 3
- How do the isolation test
- Insert many documents at once
- ConstantField produces error when converting to marshmallow schema
- DictField with an EmbeddedDocument value produces error
- Referencing GridFS data?
- [RFC] Drop txmongo support? HOT 2
- Warning: The 'missing' attribute of fields is deprecated HOT 1
- Passing marshmallow Schema options to the models HOT 2
- Add commit_many() function to perform builk updates HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from umongo.