Permalink
Browse files

Make the tests pass on patched version of django

  • Loading branch information...
1 parent 819f2d3 commit 90be77cb356a7b65410df3f52407cc38da2f8e22 @gavinwahl committed Apr 16, 2013
Showing with 7 additions and 4 deletions.
  1. +7 −4 ool/__init__.py
View
@@ -56,14 +56,14 @@ class VersionedMixin(object):
ConcurrentUpdate will be raised.
"""
- def _do_update(self, base_qs, using, pk_val, values):
+ def _do_update(self, base_qs, using, pk_val, values, update_fields):
version_field = self.get_version_field()
# _do_update is called once for each model in the inheritance
# hierarchy. We only care about the model with the version field.
if version_field.model != base_qs.model:
return super(VersionedMixin, self)._do_update(
- base_qs, using, pk_val, values)
+ base_qs, using, pk_val, values, update_fields)
# pre_save may or may not have been called at this point, based on if
# version_field is in update_fields. Since we need to reliably know the
@@ -86,8 +86,11 @@ def _do_update(self, base_qs, using, pk_val, values):
version_field.attname: old_version,
}
- nrows = base_qs.filter(**filter_kwargs)._update(values)
- if nrows < 1:
+ if not values:
+ updated = int(base_qs.filter(**filter_kwargs).exists())
+ else:
+ updated = base_qs.filter(**filter_kwargs)._update(values) >= 1
+ if not updated:
raise ConcurrentUpdate
else:
return True

0 comments on commit 90be77c

Please sign in to comment.