Skip to content

Commit ce239c5

Browse files
committed
filters: Resolve ids of Action Required states
It seems the database may sometimes refuse to use an index when values used in a filter are not constant (i.e. come from a subquery). I noticed this behaviour on MySQL when querying for patches in an Action Required state, with the Archived filter set to Both. Since the number of Action Required states is pretty much guaranteed to be small, resolve their ids into a constant list.
1 parent 1a7374b commit ce239c5

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

patchwork/filters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ def kwargs(self):
245245
return {'state': self.state}
246246

247247
return {
248-
'state__in': State.objects.filter(action_required=True)
249-
.values('pk')
250-
.query
248+
'state__in': list(State.objects.filter(action_required=True).values_list('id'))
251249
}
252250

253251
@property

0 commit comments

Comments
 (0)