mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Fixed #14366 -- Model.objects.none().values() now correctly returns a QuerySet with no items, rather than raising an Exception. Thanks to Carl Meyer for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14084 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -1021,7 +1021,7 @@ class EmptyQuerySet(QuerySet): | ||||
|         pass | ||||
|  | ||||
|     def _clone(self, klass=None, setup=False, **kwargs): | ||||
|         c = super(EmptyQuerySet, self)._clone(klass, **kwargs) | ||||
|         c = super(EmptyQuerySet, self)._clone(klass, setup=setup, **kwargs) | ||||
|         c._result_cache = [] | ||||
|         return c | ||||
|  | ||||
|   | ||||
| @@ -4,7 +4,7 @@ from django.db import DatabaseError, connections, DEFAULT_DB_ALIAS | ||||
| from django.db.models import Count | ||||
| from django.test import TestCase | ||||
|  | ||||
| from models import Tag, Annotation, DumbCategory, Note, ExtraInfo | ||||
| from models import Tag, Annotation, DumbCategory, Note, ExtraInfo, Number | ||||
|  | ||||
| class QuerysetOrderedTests(unittest.TestCase): | ||||
|     """ | ||||
| @@ -81,3 +81,9 @@ class CloneTests(TestCase): | ||||
|             self.assertEquals(ExtraInfo.objects.filter(note__in=n_list)[0].info, 'good') | ||||
|         except: | ||||
|             self.fail('Query should be clonable') | ||||
|  | ||||
|  | ||||
| class EmptyQuerySetTests(TestCase): | ||||
|     def test_emptyqueryset_values(self): | ||||
|         "#14366 -- calling .values() on an EmptyQuerySet and then cloning that should not cause an error" | ||||
|         self.assertEqual(list(Number.objects.none().values('num').order_by('num')), []) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user