Parcourir la source

fix(query): Add human friendly operator oprions

version-14
Gavin D'souza il y a 3 ans
Parent
révision
10e4ed7c1e
1 fichiers modifiés avec 19 ajouts et 19 suppressions
  1. +19
    -19
      frappe/database/query.py

+ 19
- 19
frappe/database/query.py Voir le fichier

@@ -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,


Chargement…
Annuler
Enregistrer