mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #19173 -- Made EmptyQuerySet a marker class only
The guarantee that no queries will be made when accessing results is done by new EmptyWhere class which is used for query.where and having. Thanks to Simon Charette for reviewing and valuable suggestions.
This commit is contained in:
parent
a843539af2
commit
a2396a4c8f
11 changed files with 96 additions and 177 deletions
|
@ -4,6 +4,7 @@ from datetime import datetime
|
|||
|
||||
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
|
||||
from django.db.models.fields import Field, FieldDoesNotExist
|
||||
from django.db.models.query import EmptyQuerySet
|
||||
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
|
||||
from django.utils import six
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
@ -639,3 +640,9 @@ class ModelTest(TestCase):
|
|||
Article.objects.bulk_create([Article(headline=lazy, pub_date=datetime.now())])
|
||||
article = Article.objects.get()
|
||||
self.assertEqual(article.headline, notlazy)
|
||||
|
||||
def test_emptyqs(self):
|
||||
# Can't be instantiated
|
||||
with self.assertRaises(TypeError):
|
||||
EmptyQuerySet()
|
||||
self.assertTrue(isinstance(Article.objects.none(), EmptyQuerySet))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue