Ticket #10847: values-extra.diff

File values-extra.diff, 1.1 KB (added by Alex, 6 years ago)
  • django/db/models/query.py

    diff --git a/django/db/models/query.py b/django/db/models/query.py
    index 9323e9b..5a46293 100644
    a b class ValuesQuerySet(QuerySet): 
    747747        if self.aggregate_names is not None:
    748748            self.query.set_aggregate_mask(self.aggregate_names)
    749749
     750        if self.extra_names is not None:
     751            self.query.trim_extra_select(self.extra_names)
     752
    750753    def _clone(self, klass=None, setup=False, **kwargs):
    751754        """
    752755        Cloning a ValuesQuerySet preserves the current fields.
  • tests/regressiontests/extra_regress/models.py

    diff --git a/tests/regressiontests/extra_regress/models.py b/tests/regressiontests/extra_regress/models.py
    index fd34982..1b0d79e 100644
    a b True 
    189189>>> TestObject.objects.extra(select=SortedDict((('foo','first'),('bar','second'),('whiz','third')))).values_list('whiz', 'first', 'bar', 'id')
    190190[(u'third', u'first', u'second', 1)]
    191191
     192>>> list(TestObject.objects.filter(pk__in=TestObject.objects.extra(select={'extra': 1}).values('pk'))) == list(TestObject.objects.all())
     193True
    192194"""}
    193 
    194 
Back to Top