I created a document A.
A.field1= None
A.save().
But when I try to save the document to MongoDB, the keys with a "None" value are not inserted into the collection. The field1 disappear.
Right this is an historical decision that was taken a while ago but that I'd like to change at some point. When you set the field to None, it is removed from the document instead of being actually set to None.
I guess it was done to save a bit of space in MongoDB but I think it was a bad design decision and I'd like to change that in a near future.
@bagerard can I give a try on this one?
@MaXXXXfeng
@bagerard
To add to this, I feel like if the Field has null=False and does not have a default value, then the default value should be the "zero value" of that type.
for example:
StringField defaults to ""
IntField defaults to 0
BooleanField defaults to False
etc
Most helpful comment
Right this is an historical decision that was taken a while ago but that I'd like to change at some point. When you set the field to None, it is removed from the document instead of being actually set to None.
I guess it was done to save a bit of space in MongoDB but I think it was a bad design decision and I'd like to change that in a near future.