Skip to content

Commit

Permalink
Merge branch 'master' into feature-versioning-#242
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 2, 2021
2 parents d53d85a + 822408b commit fe53174
Show file tree
Hide file tree
Showing 7 changed files with 428 additions and 349 deletions.
15 changes: 14 additions & 1 deletion datagateway_api/common/icat/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ def create_filter(self):
where_filter = self.create_condition(self.field, "!=", self.value)
elif self.operation == "like":
where_filter = self.create_condition(self.field, "like", f"%{self.value}%")
elif self.operation == "ilike":
self.field = f"UPPER({self.field})"
where_filter = self.create_condition(
self.field, "like", f"UPPER('%{self.value}%')",
)
elif self.operation == "nlike":
where_filter = self.create_condition(
self.field, "not like", f"%{self.value}%",
)
elif self.operation == "nilike":
self.field = f"UPPER({self.field})"
where_filter = self.create_condition(
self.field, "not like", f"UPPER('%{self.value}%')",
)
elif self.operation == "lt":
where_filter = self.create_condition(self.field, "<", self.value)
elif self.operation == "lte":
Expand Down Expand Up @@ -101,7 +111,10 @@ def create_condition(attribute_name, operator, value):
# distinct filter is used in a request
jpql_value = (
f"{value}"
if operator == "in" or operator == "!=" or "o." in str(value)
if operator == "in"
or operator == "!="
or str(value).startswith("UPPER")
or "o." in str(value)
else f"'{value}'"
)

Expand Down
Loading

0 comments on commit fe53174

Please sign in to comment.