diff -r 9b24e08becc2 django/db/models/sql/compiler.py
a
|
b
|
|
703 | 703 | |
704 | 704 | yield row |
705 | 705 | |
| 706 | def has_results(self): |
| 707 | # This is always executed on a query clone, so we can modify self.query |
| 708 | self.query.add_extra({'a': 1}, None, None, None, None, None) |
| 709 | self.query.set_extra_mask(('a',)) |
| 710 | return bool(self.execute_sql(SINGLE)) |
| 711 | |
706 | 712 | def execute_sql(self, result_type=MULTI): |
707 | 713 | """ |
708 | 714 | Run the query against the database and returns the result(s). The |
diff -r 9b24e08becc2 django/db/models/sql/query.py
a
|
b
|
|
404 | 404 | |
405 | 405 | def has_results(self, using): |
406 | 406 | q = self.clone() |
407 | | q.add_extra({'a': 1}, None, None, None, None, None) |
408 | 407 | q.select = [] |
409 | 408 | q.select_fields = [] |
410 | 409 | q.default_cols = False |
411 | 410 | q.select_related = False |
412 | | q.set_extra_mask(('a',)) |
413 | 411 | q.set_aggregate_mask(()) |
414 | 412 | q.clear_ordering(True) |
415 | 413 | q.set_limits(high=1) |
416 | 414 | compiler = q.get_compiler(using=using) |
417 | | return bool(compiler.execute_sql(SINGLE)) |
| 415 | return compiler.has_results() |
418 | 416 | |
419 | 417 | def combine(self, rhs, connector): |
420 | 418 | """ |