Skip to content

Commit e05fbcc

Browse files
committed
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.
1 parent 23eb8ee commit e05fbcc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

graphene_django/fields.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def resolve_connection(cls, connection, default_manager, args, iterable):
7777
if isinstance(iterable, QuerySet):
7878
if iterable is not default_manager:
7979
default_queryset = maybe_queryset(default_manager)
80+
if default_queryset.query.distinct and not iterable.query.distinct:
81+
iterable = iterable.distinct()
82+
elif iterable.query.distinct and not default_queryset.query.distinct:
83+
default_queryset = default_queryset.distinct()
8084
iterable = cls.merge_querysets(default_queryset, iterable)
8185
_len = iterable.count()
8286
else:

graphene_django/tests/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def resolve_films(self, args, context, info):
478478
'films': {
479479
'edges': [{
480480
'node': {
481-
'genre': 'ot'
481+
'genre': 'OT'
482482
}
483483
}]
484484
}

0 commit comments

Comments
 (0)