From 71dcf73dd786f5e6d0934f5ece378c49d33368e4 Mon Sep 17 00:00:00 2001 From: John-Paul Stanford Date: Wed, 29 Jul 2020 19:57:16 +0100 Subject: [PATCH] Attempt to fix issue #156 by handling subquieries (#157) * Combine child_class passing to minimize if's Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> --- cachalot/utils.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cachalot/utils.py b/cachalot/utils.py index 7ab99be..35cebcf 100644 --- a/cachalot/utils.py +++ b/cachalot/utils.py @@ -103,7 +103,7 @@ def _find_subqueries_in_where(children): yield grand_child elif child_class is ExtraWhere: raise IsRawQuery - elif child_class is NothingNode: + elif child_class in (NothingNode, Subquery, Exists): pass else: rhs = child.rhs @@ -112,11 +112,6 @@ def _find_subqueries_in_where(children): yield rhs elif rhs_class is QuerySet: yield rhs.query - elif rhs_class is Subquery or rhs_class is Exists: - try: - yield rhs.query - except: - yield rhs.queryset.query elif rhs_class in UNCACHABLE_FUNCS: raise UncachableQuery