mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #13156 -- Ensure that exists() queries are as fast as they can be. Thanks to Jerome Leclanche for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12810 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -277,6 +277,16 @@ class Plaything(models.Model):
|
||||
|
||||
|
||||
__test__ = {'API_TESTS':"""
|
||||
>>> # Regression for #13156 -- exists() queries have minimal SQL
|
||||
>>> from django.db import connection
|
||||
>>> settings.DEBUG = True
|
||||
>>> Tag.objects.exists()
|
||||
False
|
||||
>>> # Ok - so the exist query worked - but did it include too many columns?
|
||||
>>> "id" not in connection.queries[-1]['sql'] and "name" not in connection.queries[-1]['sql']
|
||||
True
|
||||
>>> settings.DEBUG = False
|
||||
|
||||
>>> generic = NamedCategory.objects.create(name="Generic")
|
||||
>>> t1 = Tag.objects.create(name='t1', category=generic)
|
||||
>>> t2 = Tag.objects.create(name='t2', parent=t1, category=generic)
|
||||
|
||||
Reference in New Issue
Block a user