Merge pull request #302 from Demoncode/upstream

Pass through write_concern from update_one to update correctly
This commit is contained in:
Ross Lawley 2013-05-01 01:44:52 -07:00
commit 92a1f5736b
2 changed files with 14 additions and 9 deletions

View File

@ -469,7 +469,8 @@ class QuerySet(object):
.. versionadded:: 0.2 .. versionadded:: 0.2
""" """
return self.update(upsert=upsert, multi=False, write_concern=None, **update) return self.update(
upsert=upsert, multi=False, write_concern=write_concern, **update)
def with_id(self, object_id): def with_id(self, object_id):
"""Retrieve the object matching the id provided. Uses `object_id` only """Retrieve the object matching the id provided. Uses `object_id` only

View File

@ -287,15 +287,19 @@ class QuerySetTest(unittest.TestCase):
name='Test User', write_concern=write_concern) name='Test User', write_concern=write_concern)
author.save(write_concern=write_concern) author.save(write_concern=write_concern)
self.Person.objects.update(set__name='Ross', result = self.Person.objects.update(
write_concern=write_concern) set__name='Ross',write_concern={"w": 1})
self.assertEqual(result, 1)
result = self.Person.objects.update(
set__name='Ross',write_concern={"w": 0})
self.assertEqual(result, None)
author = self.Person.objects.first() result = self.Person.objects.update_one(
self.assertEqual(author.name, 'Ross') set__name='Test User', write_concern={"w": 1})
self.assertEqual(result, 1)
self.Person.objects.update_one(set__name='Test User', write_concern=write_concern) result = self.Person.objects.update_one(
author = self.Person.objects.first() set__name='Test User', write_concern={"w": 0})
self.assertEqual(author.name, 'Test User') self.assertEqual(result, None)
def test_update_update_has_a_value(self): def test_update_update_has_a_value(self):
"""Test to ensure that update is passed a value to update to""" """Test to ensure that update is passed a value to update to"""