Handle dynamic fieldnames that look like digits (#434)
This commit is contained in:
parent
473110568f
commit
5bcc454678
@ -4,6 +4,7 @@ Changelog
|
||||
|
||||
Changes in 0.8.4
|
||||
================
|
||||
- Handle dynamic fieldnames that look like digits (#434)
|
||||
- Added get_user_document and improve mongo_auth module (#423)
|
||||
- Added str representation of GridFSProxy (#424)
|
||||
- Update transform to handle docs erroneously passed to unset (#416)
|
||||
|
@ -762,7 +762,7 @@ class BaseDocument(object):
|
||||
|
||||
for field_name in parts:
|
||||
# Handle ListField indexing:
|
||||
if field_name.isdigit():
|
||||
if field_name.isdigit() and hasattr(field, 'field'):
|
||||
new_field = field.field
|
||||
fields.append(field_name)
|
||||
continue
|
||||
|
@ -3299,6 +3299,13 @@ class QuerySetTest(unittest.TestCase):
|
||||
Test.objects(test='foo').update_one(upsert=True, set__test='foo')
|
||||
self.assertTrue('_cls' in Test._collection.find_one())
|
||||
|
||||
def test_update_upsert_looks_like_a_digit(self):
|
||||
class MyDoc(DynamicDocument):
|
||||
pass
|
||||
MyDoc.drop_collection()
|
||||
self.assertEqual(1, MyDoc.objects.update_one(upsert=True, inc__47=1))
|
||||
self.assertEqual(MyDoc.objects.get()['47'], 1)
|
||||
|
||||
def test_read_preference(self):
|
||||
class Bar(Document):
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user