Fix failing unit test by handling cases where a connection is resolved involving a query with inner join and distinct that is then filtered and would be combined with a filtered queryset that is not distinct.

This commit is contained in:
Daniel Bachler 2017-10-11 15:54:00 +02:00
parent 23eb8eea80
commit e05fbcc1b3
2 changed files with 5 additions and 1 deletions

View File

@ -77,6 +77,10 @@ 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:

View File

@ -478,7 +478,7 @@ def test_should_query_node_filtering_with_distinct_queryset():
'films': {
'edges': [{
'node': {
'genre': 'ot'
'genre': 'OT'
}
}]
}