Skip to content

Commit

Permalink
Create WhereFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Jul 29, 2019
1 parent 40af194 commit 202c009
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def execute_query(self):
record.CREATE_TIME = datetime.datetime.now()
record.MOD_TIME = datetime.datetime.now()
record.CREATE_ID = "user"
record.MOD_ID = "user" # These will need changing
record.MOD_ID = "user" # These will need changing
self.session.add(record)
self.commit_changes()

Expand Down Expand Up @@ -118,6 +118,16 @@ class QueryFilter(ABC):
def apply_filter(self, query):
pass


class WhereFilter(QueryFilter):
def __init__(self, field, value):
self.field = field
self.value = value

def apply_filter(self, query):
query.base_query = query.base_query.filter(getattr(query.table, self.field) == self.value)


def insert_row_into_table(row):
"""
Insert the given row into its table
Expand Down

0 comments on commit 202c009

Please sign in to comment.