From 10e4ed7c1e44c69697391fbd85dbd03aebee158b Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 31 Mar 2022 13:38:32 +0530 Subject: [PATCH] fix(query): Add human friendly operator oprions --- frappe/database/query.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/frappe/database/query.py b/frappe/database/query.py index 15ab85ff56..a8a1271e70 100644 --- a/frappe/database/query.py +++ b/frappe/database/query.py @@ -115,21 +115,23 @@ def change_orderby(order: str): OPERATOR_MAP = { - "+": operator.add, - "=": operator.eq, - "-": operator.sub, - "!=": operator.ne, - "<": operator.lt, - ">": operator.gt, - "<=": operator.le, - ">=": operator.ge, - "in": func_in, - "not in": func_not_in, - "like": like, - "not like": not_like, - "regex": func_regex, - "between": func_between - } + "+": operator.add, + "=": operator.eq, + "-": operator.sub, + "!=": operator.ne, + "<": operator.lt, + ">": operator.gt, + "<=": operator.le, + "=>": operator.le, + ">=": operator.ge, + "=>": operator.ge, + "in": func_in, + "not in": func_not_in, + "like": like, + "not like": not_like, + "regex": func_regex, + "between": func_between, +} class Query: @@ -211,8 +213,7 @@ class Query: _operator = OPERATOR_MAP[f[1]] conditions = conditions.where(_operator(Field(f[0]), f[2])) - conditions = self.add_conditions(conditions, **kwargs) - return conditions + return self.add_conditions(conditions, **kwargs) def dict_query(self, table: str, filters: Dict[str, Union[str, int]] = None, **kwargs) -> frappe.qb: """Build conditions using the given dictionary filters @@ -251,8 +252,7 @@ class Query: field = getattr(_table, key) conditions = conditions.where(field.isnull()) - conditions = self.add_conditions(conditions, **kwargs) - return conditions + return self.add_conditions(conditions, **kwargs) def build_conditions( self,