瀏覽代碼

fix(query): Add human friendly operator oprions

version-14
Gavin D'souza 3 年之前
父節點
當前提交
10e4ed7c1e
共有 1 個檔案被更改,包括 19 行新增19 行删除
  1. +19
    -19
      frappe/database/query.py

+ 19
- 19
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,


Loading…
取消
儲存