summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Bordage <bordage.bertrand@gmail.com>2017-06-03 20:02:23 (GMT)
committerBertrand Bordage <bordage.bertrand@gmail.com>2017-06-03 20:02:23 (GMT)
commit84c53cd00def4fe422ba400ebb26c9079add37f6 (patch)
treec3de9e9520765d75dd8d5650f025678d0fdce6ef
parent809ef63fd9b75d24379b4d6b560490cc004dbbd1 (diff)
downloaddjango-cachalot-84c53cd00def4fe422ba400ebb26c9079add37f6.zip
django-cachalot-84c53cd00def4fe422ba400ebb26c9079add37f6.tar.gz
django-cachalot-84c53cd00def4fe422ba400ebb26c9079add37f6.tar.bz2
Invalidates queries on schema changes.
-rw-r--r--cachalot/monkey_patch.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/cachalot/monkey_patch.py b/cachalot/monkey_patch.py
index f48cc17..0ca0ef6 100644
--- a/cachalot/monkey_patch.py
+++ b/cachalot/monkey_patch.py
@@ -5,8 +5,8 @@ from collections import Iterable
from functools import wraps
from time import time
+from django.core.exceptions import EmptyResultSet
from django.db.backends.utils import CursorWrapper
-from django.db.models.query import EmptyResultSet
from django.db.models.signals import post_migrate
from django.db.models.sql.compiler import (
SQLCompiler, SQLInsertCompiler, SQLUpdateCompiler, SQLDeleteCompiler,
@@ -114,7 +114,8 @@ def _patch_cursor():
if isinstance(sql, binary_type):
sql = sql.decode('utf-8')
sql = sql.lower()
- if 'update' in sql or 'insert' in sql or 'delete' in sql:
+ if 'update' in sql or 'insert' in sql or 'delete' in sql \
+ or 'alter' in sql or 'create' in sql or 'drop' in sql:
tables = filter_cachable(
set(_get_tables_from_sql(cursor.db, sql)))
if tables: