From 42af2e01269ab442970d2fa1d9e9f4fc044dd408 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Tue, 26 Oct 2021 22:34:45 +0200 Subject: [PATCH] Handle queryset implementations without lhs/rhs attribute (#204) The `ExtraJoinRestriction` class used by django-taggit lacks the attributes "rhs" and "lhs". Thus projects cannot use django-taggit together with cachalot. Closes: #121 --- cachalot/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cachalot/utils.py b/cachalot/utils.py index da5f2e4..f228701 100644 --- a/cachalot/utils.py +++ b/cachalot/utils.py @@ -135,10 +135,15 @@ def _find_subqueries_in_where(children): elif child_class is NothingNode: pass else: - rhs = _find_rhs_lhs_subquery(child.rhs) + try: + child_rhs = child.rhs + child_lhs = child.lhs + except AttributeError: + raise UncachableQuery + rhs = _find_rhs_lhs_subquery(child_rhs) if rhs is not None: yield rhs - lhs = _find_rhs_lhs_subquery(child.lhs) + lhs = _find_rhs_lhs_subquery(child_lhs) if lhs is not None: yield lhs