Don't run unset on IntField if the value is 0 (zero).
The IntField in unset if the IntField value doesn't validate to "truthify" (therefore, is set as 0) and the default value of the IntField in question is 0. This is not a logical functionality in my opinion. Take this example. You have an IntField that is a counter which can be incremented and decremented. This counter has the default value of 0 and is a required field. Every time the counter reaches 0, the field is unset.
This commit is contained in:
parent
47df8deb58
commit
7e980a16d0
@ -1207,7 +1207,7 @@ class BaseDocument(object):
|
|||||||
|
|
||||||
# Determine if any changed items were actually unset.
|
# Determine if any changed items were actually unset.
|
||||||
for path, value in set_data.items():
|
for path, value in set_data.items():
|
||||||
if value or type(value) in [bool, int]:
|
if value or isinstance(value, (bool, int)):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# If we've set a value that ain't the default value dont unset it.
|
# If we've set a value that ain't the default value dont unset it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user