(self, limit=True)
| 659 | return self.where |
| 660 | |
| 661 | def exists(self, limit=True): |
| 662 | q = self.clone() |
| 663 | if not (q.distinct and q.is_sliced): |
| 664 | if q.group_by is True: |
| 665 | q.add_fields( |
| 666 | (f.attname for f in self.model._meta.concrete_fields), False |
| 667 | ) |
| 668 | # Disable GROUP BY aliases to avoid orphaning references to the |
| 669 | # SELECT clause which is about to be cleared. |
| 670 | q.set_group_by(allow_aliases=False) |
| 671 | q.clear_select_clause() |
| 672 | if q.combined_queries and q.combinator == "union": |
| 673 | q.combined_queries = tuple( |
| 674 | combined_query.exists(limit=False) |
| 675 | for combined_query in q.combined_queries |
| 676 | ) |
| 677 | q.clear_ordering(force=True) |
| 678 | if limit is True: |
| 679 | q.set_limits(high=1) |
| 680 | q.add_annotation(Value(1), "a") |
| 681 | return q |
| 682 | |
| 683 | def has_results(self, using): |
| 684 | q = self.exists() |
no test coverage detected