Move distinct check code to merge_querysets again

This commit is contained in:
Daniel Bachler 2018-02-28 17:52:27 +01:00
parent 4d41160379
commit 34f5978446

View File

@ -67,6 +67,10 @@ class DjangoConnectionField(ConnectionField):
@classmethod
def merge_querysets(cls, default_queryset, queryset):
if default_queryset.query.distinct and not queryset.query.distinct:
queryset = queryset.distinct()
elif queryset.query.distinct and not default_queryset.query.distinct:
default_queryset = default_queryset.distinct()
return queryset & default_queryset
@classmethod
@ -77,10 +81,6 @@ class DjangoConnectionField(ConnectionField):
if isinstance(iterable, QuerySet):
if iterable is not default_manager:
default_queryset = maybe_queryset(default_manager)
if default_queryset.query.distinct and not iterable.query.distinct:
iterable = iterable.distinct()
elif iterable.query.distinct and not default_queryset.query.distinct:
default_queryset = default_queryset.distinct()
iterable = cls.merge_querysets(default_queryset, iterable)
_len = iterable.count()
else: