mirror of https://github.com/django/django.git
[1.8.x] Refs #20625 -- Fixed custom queryset chaining with values() and values_list().
This commit is contained in:
parent
4f0966e75f
commit
7d471fe662
|
@ -937,10 +937,10 @@ class QuerySet(object):
|
||||||
using=self.db)
|
using=self.db)
|
||||||
|
|
||||||
def _clone(self, klass=None, setup=False, **kwargs):
|
def _clone(self, klass=None, setup=False, **kwargs):
|
||||||
|
base_queryset_class = getattr(self, '_base_queryset_class', self.__class__)
|
||||||
if klass is None:
|
if klass is None:
|
||||||
klass = self.__class__
|
klass = self.__class__
|
||||||
elif not issubclass(self.__class__, klass):
|
elif not (issubclass(base_queryset_class, klass) or issubclass(klass, base_queryset_class)):
|
||||||
base_queryset_class = getattr(self, '_base_queryset_class', self.__class__)
|
|
||||||
class_bases = (klass, base_queryset_class)
|
class_bases = (klass, base_queryset_class)
|
||||||
class_dict = {
|
class_dict = {
|
||||||
'_base_queryset_class': base_queryset_class,
|
'_base_queryset_class': base_queryset_class,
|
||||||
|
|
|
@ -36,3 +36,6 @@ Bugfixes
|
||||||
* Changed ``Count`` queries to execute ``COUNT(*)`` instead of ``COUNT('*')``
|
* Changed ``Count`` queries to execute ``COUNT(*)`` instead of ``COUNT('*')``
|
||||||
as versions of Django before 1.8 did (:ticket:`25377`). This may fix a
|
as versions of Django before 1.8 did (:ticket:`25377`). This may fix a
|
||||||
performance regression on some databases.
|
performance regression on some databases.
|
||||||
|
|
||||||
|
* Fixed custom queryset chaining with ``values()`` and ``values_list()``
|
||||||
|
(:ticket:`20625`).
|
||||||
|
|
|
@ -76,6 +76,10 @@ class CustomManagerTests(TestCase):
|
||||||
self.assertEqual(list(queryset), [six.text_type("Bugs")])
|
self.assertEqual(list(queryset), [six.text_type("Bugs")])
|
||||||
self.assertEqual(queryset._filter_CustomQuerySet, True)
|
self.assertEqual(queryset._filter_CustomQuerySet, True)
|
||||||
|
|
||||||
|
self.assertIsInstance(queryset.values(), CustomQuerySet)
|
||||||
|
self.assertIsInstance(queryset.values().values(), CustomQuerySet)
|
||||||
|
self.assertIsInstance(queryset.values_list().values(), CustomQuerySet)
|
||||||
|
|
||||||
def test_init_args(self):
|
def test_init_args(self):
|
||||||
"""
|
"""
|
||||||
The custom manager __init__() argument has been set.
|
The custom manager __init__() argument has been set.
|
||||||
|
|
Loading…
Reference in New Issue