Skip to content

Commit

Permalink
Avoids extra invalidations during write operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Oct 28, 2015
1 parent dcfffbc commit 7177361
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions cachalot/monkey_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def inner(compiler, *args, **kwargs):

def _patch_write_compiler(original):
@wraps(original)
@_unset_raw_connection
def inner(write_compiler, *args, **kwargs):
db_alias = write_compiler.using
table = write_compiler.query.get_meta().db_table
Expand Down
2 changes: 1 addition & 1 deletion cachalot/tests/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def test_invalidate_prefetch_related(self):
permissions = list(Permission.objects.all()[:5])
group.permissions.add(*permissions)
u.groups.add(group)
with self.assertNumQueries(3):
with self.assertNumQueries(2):
data4 = list(Test.objects.select_related('owner')
.prefetch_related('owner__groups__permissions'))
self.assertListEqual(data4, [t1])
Expand Down

0 comments on commit 7177361

Please sign in to comment.