Add a Q-object to the current filter.
(
self,
q_object,
used_aliases,
branch_negated=False,
current_negated=False,
allow_joins=True,
split_subq=True,
check_filterable=True,
summarize=False,
update_join_types=True,
)
| 1689 | self.where = WhereNode() |
| 1690 | |
| 1691 | def _add_q( |
| 1692 | self, |
| 1693 | q_object, |
| 1694 | used_aliases, |
| 1695 | branch_negated=False, |
| 1696 | current_negated=False, |
| 1697 | allow_joins=True, |
| 1698 | split_subq=True, |
| 1699 | check_filterable=True, |
| 1700 | summarize=False, |
| 1701 | update_join_types=True, |
| 1702 | ): |
| 1703 | """Add a Q-object to the current filter.""" |
| 1704 | connector = q_object.connector |
| 1705 | current_negated ^= q_object.negated |
| 1706 | branch_negated = branch_negated or q_object.negated |
| 1707 | target_clause = WhereNode(connector=connector, negated=q_object.negated) |
| 1708 | joinpromoter = JoinPromoter( |
| 1709 | q_object.connector, len(q_object.children), current_negated |
| 1710 | ) |
| 1711 | for child in q_object.children: |
| 1712 | child_clause, needed_inner = self.build_filter( |
| 1713 | child, |
| 1714 | can_reuse=used_aliases, |
| 1715 | branch_negated=branch_negated, |
| 1716 | current_negated=current_negated, |
| 1717 | allow_joins=allow_joins, |
| 1718 | split_subq=split_subq, |
| 1719 | check_filterable=check_filterable, |
| 1720 | summarize=summarize, |
| 1721 | update_join_types=update_join_types, |
| 1722 | ) |
| 1723 | joinpromoter.add_votes(needed_inner) |
| 1724 | if child_clause: |
| 1725 | target_clause.add(child_clause, connector) |
| 1726 | if update_join_types: |
| 1727 | needed_inner = joinpromoter.update_join_types(self) |
| 1728 | else: |
| 1729 | needed_inner = [] |
| 1730 | return target_clause, needed_inner |
| 1731 | |
| 1732 | def add_filtered_relation(self, filtered_relation, alias): |
| 1733 | if "." in alias: |
no test coverage detected