filter_q: allow empty Q() objects

This commit is contained in:
Laura Klünder 2017-07-13 19:32:04 +02:00
parent eaf1d20427
commit 9fff9e5dcb

View file

@ -603,6 +603,8 @@ class BaseQueryWrapper(BaseWrapper):
Split it up into recursive _filter_q and _filter_kwarg calls and combine them again.
:return: new Q object and set of matched existing pks
"""
if not q.children:
return q, self._get_initial_created_pks()
filters, created_pks = zip(*((self._filter_q(c) if isinstance(c, Q) else self._filter_kwarg(*c))
for c in q.children))
result = Q(*filters)