Ticket #14366: 14366_r13962.diff

File 14366_r13962.diff, 1.5 KB (added by Carl Meyer, 14 years ago)
  • django/db/models/query.py

    diff --git a/django/db/models/query.py b/django/db/models/query.py
    index e16fca1..edb0991 100644
    a b class EmptyQuerySet(QuerySet):  
    10211021        pass
    10221022
    10231023    def _clone(self, klass=None, setup=False, **kwargs):
    1024         c = super(EmptyQuerySet, self)._clone(klass, **kwargs)
     1024        c = super(EmptyQuerySet, self)._clone(klass, setup=setup, **kwargs)
    10251025        c._result_cache = []
    10261026        return c
    10271027
  • tests/regressiontests/queries/tests.py

    diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
    index 03c28b0..75653fc 100644
    a b from django.db import DatabaseError, connections, DEFAULT_DB_ALIAS  
    44from django.db.models import Count
    55from django.test import TestCase
    66
    7 from models import Tag, Annotation, DumbCategory, Note, ExtraInfo
     7from models import Tag, Annotation, DumbCategory, Note, ExtraInfo, Number
    88
    99class QuerysetOrderedTests(unittest.TestCase):
    1010    """
    class CloneTests(TestCase):  
    8181            self.assertEquals(ExtraInfo.objects.filter(note__in=n_list)[0].info, 'good')
    8282        except:
    8383            self.fail('Query should be clonable')
     84
     85
     86class EmptyQuerySetTests(TestCase):
     87    def test_emptyqueryset_values(self):
     88        "#14366 -- calling .values() on an EmptyQuerySet and then cloning that should not cause an error"
     89        self.assertEqual(list(Number.objects.none().values('num').order_by('num')), [])
Back to Top