Fix #595: Support += and *= for ListField
This commit is contained in:
parent
cbd2a44350
commit
de0e5583a5
@ -5,6 +5,10 @@ Changelog
|
||||
|
||||
Changes in 0.9.X - DEV
|
||||
======================
|
||||
- Support += and *= for ListField #595
|
||||
|
||||
Changes in 0.9.0
|
||||
================
|
||||
- Update FileField when creating a new file #714
|
||||
- Added `EmbeddedDocumentListField` for Lists of Embedded Documents. #826
|
||||
- ComplexDateTimeField should fall back to None when null=True #864
|
||||
|
@ -156,6 +156,14 @@ class BaseList(list):
|
||||
self = state
|
||||
return self
|
||||
|
||||
def __iadd__(self, other):
|
||||
self._mark_as_changed()
|
||||
return super(BaseList, self).__iadd__(other)
|
||||
|
||||
def __imul__(self, other):
|
||||
self._mark_as_changed()
|
||||
return super(BaseList, self).__imul__(other)
|
||||
|
||||
def append(self, *args, **kwargs):
|
||||
self._mark_as_changed()
|
||||
return super(BaseList, self).append(*args, **kwargs)
|
||||
|
@ -946,6 +946,18 @@ class FieldTest(unittest.TestCase):
|
||||
BlogPost.objects.filter(info__0__test__exact='5').count(), 0)
|
||||
self.assertEqual(
|
||||
BlogPost.objects.filter(info__100__test__exact='test').count(), 0)
|
||||
|
||||
post = BlogPost()
|
||||
post.info = ['1', '2']
|
||||
post.save()
|
||||
post = BlogPost.objects(info=['1', '2']).get()
|
||||
post.info += ['3', '4']
|
||||
post.save()
|
||||
self.assertEqual(BlogPost.objects(info=['1', '2', '3', '4']).count(), 1)
|
||||
post = BlogPost.objects(info=['1', '2', '3', '4']).get()
|
||||
post.info *= 2
|
||||
post.save()
|
||||
self.assertEqual(BlogPost.objects(info=['1', '2', '3', '4', '1', '2', '3', '4']).count(), 1)
|
||||
BlogPost.drop_collection()
|
||||
|
||||
def test_list_field_passed_in_value(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user