Fix .non_polymorphic(), returns a copy of the queryset
Just like .filter() and such do.fix_request_path_info
parent
61e9a8050a
commit
e1093ff1fb
|
|
@ -1,6 +1,12 @@
|
|||
Changelog
|
||||
==========
|
||||
|
||||
Version 0.5.4 (in development)
|
||||
------------------------------
|
||||
|
||||
* Fix ``.non_polymorphic()`` to returns a clone of the queryset, instead of effecting the existing queryset.
|
||||
|
||||
|
||||
Version 0.5.3 (2013-09-17)
|
||||
--------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -67,8 +67,9 @@ class PolymorphicQuerySet(QuerySet):
|
|||
"""switch off polymorphic behaviour for this query.
|
||||
When the queryset is evaluated, only objects of the type of the
|
||||
base class used for this query are returned."""
|
||||
self.polymorphic_disabled = True
|
||||
return self
|
||||
qs = self._clone()
|
||||
qs.polymorphic_disabled = True
|
||||
return qs
|
||||
|
||||
def instance_of(self, *args):
|
||||
"""Filter the queryset to only include the classes in args (and their subclasses).
|
||||
|
|
@ -109,8 +110,8 @@ class PolymorphicQuerySet(QuerySet):
|
|||
"""translate the polymorphic field paths in the kwargs, then call vanilla aggregate.
|
||||
We need no polymorphic object retrieval for aggregate => switch it off."""
|
||||
self._process_aggregate_args(args, kwargs)
|
||||
self.polymorphic_disabled = True
|
||||
return super(PolymorphicQuerySet, self).aggregate(*args, **kwargs)
|
||||
qs = self.non_polymorphic()
|
||||
return super(PolymorphicQuerySet, qs).aggregate(*args, **kwargs)
|
||||
|
||||
# Since django_polymorphic 'V1.0 beta2', extra() always returns polymorphic results.^
|
||||
# The resulting objects are required to have a unique primary key within the result set
|
||||
|
|
|
|||
Loading…
Reference in New Issue