fix(query): Add human friendly operator oprions
This commit is contained in:
parent
459c179916
commit
10e4ed7c1e
1 changed files with 19 additions and 19 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue