mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge pull request #8793 from seros1521/fix_8715
Fixes #8715: eliminates duplicates when used in many-to-many field constraints
This commit is contained in:
@ -39,6 +39,12 @@ class RestrictedQuerySet(QuerySet):
|
||||
# Any permission with null constraints grants access to _all_ instances
|
||||
attrs = Q()
|
||||
break
|
||||
else:
|
||||
# for else, when no break
|
||||
# avoid duplicates when JOIN on many-to-many fields without using DISTINCT.
|
||||
# DISTINCT acts globally on the entire request, which may not be desirable.
|
||||
allowed_objects = self.model.objects.filter(attrs)
|
||||
attrs = Q(pk__in=allowed_objects)
|
||||
qs = self.filter(attrs)
|
||||
|
||||
return qs
|
||||
|
Reference in New Issue
Block a user