Open
Description
Using a combined filter, in one of the expressions of which negation is used, the exception appears:
Traceback (most recent call last):
File "C:\Users\Roman\AppData\Local\Programs\PyCharm Professional\plugins\python\helpers\pydev\pydevconsole.py", line 364, in runcode
coro = func()
^^^^^^
File "<input>", line 1, in <module>
File "C:\Users\Roman\PycharmProjects\tugan-mono\projects\server\venv\Lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Roman\PycharmProjects\tugan-mono\projects\server\venv\Lib\site-packages\eav\queryset.py", line 175, in wrapper
arg = rewrite_q_expr(self.model, arg)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Roman\PycharmProjects\tugan-mono\projects\server\venv\Lib\site-packages\eav\queryset.py", line 107, in rewrite_q_expr
rewritable = [c for c in expr.children if is_eav_and_leaf(c, gr_name)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Roman\PycharmProjects\tugan-mono\projects\server\venv\Lib\site-packages\eav\queryset.py", line 107, in <listcomp>
rewritable = [c for c in expr.children if is_eav_and_leaf(c, gr_name)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Roman\PycharmProjects\tugan-mono\projects\server\venv\Lib\site-packages\eav\queryset.py", line 48, in is_eav_and_leaf
and expr.children[0][0] in ['pk__in', '{}__in'.format(gr_name)]
~~~~~~~~~~~~~~~~^^^
TypeError: 'Q' object is not subscriptable
Expression that called exception:
ForeignProduct.objects.filter(Q(id=86) & ~Q(marketplace_user_id=1))
The model code is quite large, because there is inheritance. But if it is needed, I will send it.
In the project, I got around this bug by using the exclude method for expressions with negation, but it isn't solution.
Steps to Reproduce
Just filter some EavQuerySet with more than 1 expression, one of which is negated.
Your Environment
Include relevant details about the environment you experienced the bug in.
- Version used: 1.6.1
- Environment name and version (e.g. Django 2.0.4, pip 9.0.1): Django 3.2.9
- Operating System and version: Windows / Ubuntu
Metadata
Metadata
Assignees
Labels
No labels