|
@@ -115,21 +115,23 @@ def change_orderby(order: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OPERATOR_MAP = { |
|
|
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: |
|
|
class Query: |
|
@@ -211,8 +213,7 @@ class Query: |
|
|
_operator = OPERATOR_MAP[f[1]] |
|
|
_operator = OPERATOR_MAP[f[1]] |
|
|
conditions = conditions.where(_operator(Field(f[0]), f[2])) |
|
|
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: |
|
|
def dict_query(self, table: str, filters: Dict[str, Union[str, int]] = None, **kwargs) -> frappe.qb: |
|
|
"""Build conditions using the given dictionary filters |
|
|
"""Build conditions using the given dictionary filters |
|
@@ -251,8 +252,7 @@ class Query: |
|
|
field = getattr(_table, key) |
|
|
field = getattr(_table, key) |
|
|
conditions = conditions.where(field.isnull()) |
|
|
conditions = conditions.where(field.isnull()) |
|
|
|
|
|
|
|
|
conditions = self.add_conditions(conditions, **kwargs) |
|
|
|
|
|
return conditions |
|
|
|
|
|
|
|
|
return self.add_conditions(conditions, **kwargs) |
|
|
|
|
|
|
|
|
def build_conditions( |
|
|
def build_conditions( |
|
|
self, |
|
|
self, |
|
|