Merge pull request #1270 from Neurostack/master
Bug fixed accessing BaseList with negative indices
This commit is contained in:
commit
ab10217c86
1
AUTHORS
1
AUTHORS
@ -236,3 +236,4 @@ that much better:
|
|||||||
* Luo Peng (https://github.com/RussellLuo)
|
* Luo Peng (https://github.com/RussellLuo)
|
||||||
* Bryan Bennett (https://github.com/bbenne10)
|
* Bryan Bennett (https://github.com/bbenne10)
|
||||||
* Gilb's Gilb's (https://github.com/gilbsgilbs)
|
* Gilb's Gilb's (https://github.com/gilbsgilbs)
|
||||||
|
* Joshua Nedrud (https://github.com/Neurostack)
|
||||||
|
@ -11,6 +11,7 @@ Changes in 0.10.7 - DEV
|
|||||||
- count on ListField of EmbeddedDocumentField fails. #1187
|
- count on ListField of EmbeddedDocumentField fails. #1187
|
||||||
- Fixed long fields stored as int32 in Python 3. #1253
|
- Fixed long fields stored as int32 in Python 3. #1253
|
||||||
- MapField now handles unicodes keys correctly. #1267
|
- MapField now handles unicodes keys correctly. #1267
|
||||||
|
- ListField now handles negative indicies correctly. #1270
|
||||||
|
|
||||||
Changes in 0.10.6
|
Changes in 0.10.6
|
||||||
=================
|
=================
|
||||||
|
@ -199,7 +199,8 @@ class BaseList(list):
|
|||||||
def _mark_as_changed(self, key=None):
|
def _mark_as_changed(self, key=None):
|
||||||
if hasattr(self._instance, '_mark_as_changed'):
|
if hasattr(self._instance, '_mark_as_changed'):
|
||||||
if key:
|
if key:
|
||||||
self._instance._mark_as_changed('%s.%s' % (self._name, key))
|
self._instance._mark_as_changed('%s.%s' % (self._name,
|
||||||
|
key % len(self)))
|
||||||
else:
|
else:
|
||||||
self._instance._mark_as_changed(self._name)
|
self._instance._mark_as_changed(self._name)
|
||||||
|
|
||||||
|
@ -1160,6 +1160,19 @@ class FieldTest(unittest.TestCase):
|
|||||||
simple = simple.reload()
|
simple = simple.reload()
|
||||||
self.assertEqual(simple.widgets, [4])
|
self.assertEqual(simple.widgets, [4])
|
||||||
|
|
||||||
|
def test_list_field_with_negative_indices(self):
|
||||||
|
|
||||||
|
class Simple(Document):
|
||||||
|
widgets = ListField()
|
||||||
|
|
||||||
|
simple = Simple(widgets=[1, 2, 3, 4]).save()
|
||||||
|
simple.widgets[-1] = 5
|
||||||
|
self.assertEqual(['widgets.3'], simple._changed_fields)
|
||||||
|
simple.save()
|
||||||
|
|
||||||
|
simple = simple.reload()
|
||||||
|
self.assertEqual(simple.widgets, [1, 2, 3, 5])
|
||||||
|
|
||||||
def test_list_field_complex(self):
|
def test_list_field_complex(self):
|
||||||
"""Ensure that the list fields can handle the complex types."""
|
"""Ensure that the list fields can handle the complex types."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user