Fixed recursion loading bug in _get_changed_fields
fixes hmarr/mongoengine#548
This commit is contained in:
parent
24fd1acce6
commit
6526923345
@ -3,6 +3,10 @@ Changelog
|
|||||||
=========
|
=========
|
||||||
|
|
||||||
|
|
||||||
|
Changes in 0.6.18
|
||||||
|
=================
|
||||||
|
- Fixed recursion loading bug in _get_changed_fields
|
||||||
|
|
||||||
Changes in 0.6.17
|
Changes in 0.6.17
|
||||||
=================
|
=================
|
||||||
- Fixed issue with custom queryset manager expecting explict variable names
|
- Fixed issue with custom queryset manager expecting explict variable names
|
||||||
|
@ -12,7 +12,7 @@ from signals import *
|
|||||||
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
|
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
|
||||||
queryset.__all__ + signals.__all__)
|
queryset.__all__ + signals.__all__)
|
||||||
|
|
||||||
VERSION = (0, 6, 17)
|
VERSION = (0, 6, 18)
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
|
@ -1012,9 +1012,10 @@ Invalid data to create a `%s` instance.\n%s""".strip() % (cls._class_name, error
|
|||||||
field_list.update(self._dynamic_fields)
|
field_list.update(self._dynamic_fields)
|
||||||
|
|
||||||
for field_name in field_list:
|
for field_name in field_list:
|
||||||
|
|
||||||
db_field_name = self._db_field_map.get(field_name, field_name)
|
db_field_name = self._db_field_map.get(field_name, field_name)
|
||||||
key = '%s.' % db_field_name
|
key = '%s.' % db_field_name
|
||||||
field = getattr(self, field_name, None)
|
field = self._data.get(field_name, None)
|
||||||
if hasattr(field, 'id'):
|
if hasattr(field, 'id'):
|
||||||
if field.id in inspected:
|
if field.id in inspected:
|
||||||
continue
|
continue
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
%define srcname mongoengine
|
%define srcname mongoengine
|
||||||
|
|
||||||
Name: python-%{srcname}
|
Name: python-%{srcname}
|
||||||
Version: 0.6.17
|
Version: 0.6.18
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: A Python Document-Object Mapper for working with MongoDB
|
Summary: A Python Document-Object Mapper for working with MongoDB
|
||||||
|
|
||||||
|
@ -579,6 +579,64 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
Blog.objects.insert([blog2, blog3], write_options={'continue_on_error': True})
|
Blog.objects.insert([blog2, blog3], write_options={'continue_on_error': True})
|
||||||
self.assertEqual(Blog.objects.count(), 3)
|
self.assertEqual(Blog.objects.count(), 3)
|
||||||
|
|
||||||
|
def test_get_changed_fields_query_count(self):
|
||||||
|
|
||||||
|
class Person(Document):
|
||||||
|
name = StringField()
|
||||||
|
owns = ListField(ReferenceField('Organization'))
|
||||||
|
projects = ListField(ReferenceField('Project'))
|
||||||
|
|
||||||
|
class Organization(Document):
|
||||||
|
name = StringField()
|
||||||
|
owner = ReferenceField('Person')
|
||||||
|
employees = ListField(ReferenceField('Person'))
|
||||||
|
|
||||||
|
class Project(Document):
|
||||||
|
name = StringField()
|
||||||
|
|
||||||
|
Person.drop_collection()
|
||||||
|
Organization.drop_collection()
|
||||||
|
Project.drop_collection()
|
||||||
|
|
||||||
|
r1 = Project(name="r1").save()
|
||||||
|
r2 = Project(name="r2").save()
|
||||||
|
r3 = Project(name="r3").save()
|
||||||
|
p1 = Person(name="p1", projects=[r1, r2]).save()
|
||||||
|
p2 = Person(name="p2", projects=[r2]).save()
|
||||||
|
o1 = Organization(name="o1", employees=[p1]).save()
|
||||||
|
|
||||||
|
with query_counter() as q:
|
||||||
|
self.assertEqual(q, 0)
|
||||||
|
|
||||||
|
fresh_o1 = Organization.objects.get(id=o1.id)
|
||||||
|
self.assertEqual(1, q)
|
||||||
|
fresh_o1._get_changed_fields()
|
||||||
|
self.assertEqual(1, q)
|
||||||
|
|
||||||
|
with query_counter() as q:
|
||||||
|
self.assertEqual(q, 0)
|
||||||
|
|
||||||
|
fresh_o1 = Organization.objects.get(id=o1.id)
|
||||||
|
fresh_o1.save()
|
||||||
|
|
||||||
|
self.assertEquals(q, 2)
|
||||||
|
|
||||||
|
with query_counter() as q:
|
||||||
|
self.assertEqual(q, 0)
|
||||||
|
|
||||||
|
fresh_o1 = Organization.objects.get(id=o1.id)
|
||||||
|
fresh_o1.save(cascade=False)
|
||||||
|
|
||||||
|
self.assertEquals(q, 2)
|
||||||
|
|
||||||
|
with query_counter() as q:
|
||||||
|
self.assertEqual(q, 0)
|
||||||
|
|
||||||
|
fresh_o1 = Organization.objects.get(id=o1.id)
|
||||||
|
fresh_o1.employees.append(p2)
|
||||||
|
fresh_o1.save(cascade=False)
|
||||||
|
|
||||||
|
self.assertEquals(q, 3)
|
||||||
|
|
||||||
def test_slave_okay(self):
|
def test_slave_okay(self):
|
||||||
"""Ensures that a query can take slave_okay syntax
|
"""Ensures that a query can take slave_okay syntax
|
||||||
|
Loading…
x
Reference in New Issue
Block a user