Skip to content

Commit

Permalink
#42: Add level 2 include filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Oct 17, 2019
1 parent 22d0be1 commit e410825
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ def apply_filter(self, query):
field = getattr(query.table, self.field)
except AttributeError:
raise BadFilterError(f"Bad WhereFilter requested")
if self.included_field:

if self.included_included_field:
included_table = getattr(db_models, self.field)
included_included_table = getattr(db_models, self.included_field)
query.base_query = query.base_query.join(included_table).join(included_included_table)
field = getattr(included_included_table, self.included_included_field)

elif self.included_field:
included_table = getattr(db_models, self.field)
query.base_query = query.base_query.join(included_table)
field = getattr(included_table, self.included_field)
Expand Down

0 comments on commit e410825

Please sign in to comment.