Merge pull request #5749 from ryanpetrello/search-distinct

fix a bug that causes __search filters to not properly call .distinct()

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-01-23 19:09:52 +00:00
committed by GitHub

View File

@@ -283,6 +283,9 @@ class FieldLookupBackend(BaseFilterBackend):
search_value, new_keys, _ = self.value_to_python(queryset.model, key, force_text(value)) search_value, new_keys, _ = self.value_to_python(queryset.model, key, force_text(value))
assert isinstance(new_keys, list) assert isinstance(new_keys, list)
search_filters[search_value] = new_keys search_filters[search_value] = new_keys
# by definition, search *only* joins across relations,
# so it _always_ needs a .distinct()
needs_distinct = True
continue continue
# Custom chain__ and or__ filters, mutually exclusive (both can # Custom chain__ and or__ filters, mutually exclusive (both can