Fix bug causing some subscription queries to use inefficient SQL.

This commit is contained in:
Tyson Clugg 2015-10-14 02:59:02 +11:00
parent f1fb3d76ab
commit 4c0fd40ebd

View file

@ -285,7 +285,7 @@ class Collection(APIMixin):
name, rel = (user_rel.split('__', 1) + [None])[:2]
field = meta.pk if name == 'pk' else meta.get_field(name)
# generate `filter_obj` (instance of django.db.models.Q)
if field not in meta.local_fields:
if field.related_model is not None:
# user_rel spans a join - ensure efficient SQL is generated
# such as `...WHERE foo_id IN (SELECT foo.id FROM ...)`
# rather than creating an explosion of INNER JOINS.