Skip to content

Commit

Permalink
Revert to the old behaviour with return_changes='always'
Browse files Browse the repository at this point in the history
With RethinkDB 2.0.2, `return_changes='always'` has been introduced,
which mimics the old behaviour of always returning changes even if a
document hasn’t been modified.
  • Loading branch information
linkyndy committed May 23, 2015
1 parent 9cae5ca commit 295193b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions remodel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def save(self):
id_ = fields_dict['id']
result = (r.table(self._table).get(id_).replace(r.row
.without(r.row.keys().difference(list(fields_dict.keys())))
.merge(fields_dict), return_changes=True).run())
.merge(fields_dict), return_changes='always').run())

except KeyError:
# Resort to insert
Expand All @@ -85,13 +85,8 @@ def save(self):
if result['errors'] > 0:
raise OperationError(result['first_error'])

# RethinkDB 2.0 doesn't add the 'changes' key in the result if the
# document hasn't been modified
# TODO: Follow on the discussion at linkyndy/remodel#23 and change this
# accordingly
if 'changes' in result:
# Force overwrite so that related caches are flushed
self.fields.__dict__ = result['changes'][0]['new_val']
# Force overwrite so that related caches are flushed
self.fields.__dict__ = result['changes'][0]['new_val']

self._run_callbacks('after_save')

Expand Down

0 comments on commit 295193b

Please sign in to comment.