Skip to content

Commit

Permalink
#42: Add private method to set fields and tables
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Oct 17, 2019
1 parent f1e6e8a commit 22d0be1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,22 @@ class WhereFilter(QueryFilter):
precedence = 1

def __init__(self, field, value, operation):
self.field = field if "." not in field else field.split(".")[0]
self.included_field = None if "." not in field else field.split(".")[1]
self.field = field
self._set_filter_fields()
self.value = value
self.operation = operation

def _set_filter_fields(self):
if self.field.count(".") == 1:
self.included_field = self.field.split(".")[1]
self.field = self.field.split(".")[0]

if self.field.count(".") == 2:
self.included_included_field = self.field.split(".")[2]
self.included_field = self.field.split(".")[1]
self.field = self.field.split(".")[0]


def apply_filter(self, query):
try:
field = getattr(query.table, self.field)
Expand Down

0 comments on commit 22d0be1

Please sign in to comment.