From 389aded5bf9d62e86edf7e53d0b1668ca5a38ce3 Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Fri, 17 Apr 2015 18:11:44 +0200 Subject: [PATCH] Fixes the invalidation error discovered by @helenwarren. --- cachalot/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cachalot/utils.py b/cachalot/utils.py index ebaefb4..8f685f1 100644 --- a/cachalot/utils.py +++ b/cachalot/utils.py @@ -6,6 +6,7 @@ from time import time import django from django.db import connections +from django.db.models.sql import Query from django.db.models.sql.where import ExtraWhere, SubqueryConstraint DJANGO_GTE_1_7 = django.VERSION[:2] >= (1, 7) if DJANGO_GTE_1_7: @@ -73,7 +74,9 @@ def _find_subqueries(children): rhs = child.rhs elif isinstance(child, tuple): rhs = child[-1] - if hasattr(rhs, 'query'): + if isinstance(rhs, Query): + yield rhs + elif hasattr(rhs, 'query'): yield rhs.query if hasattr(child, 'children'): for grand_child in _find_subqueries(child.children):