refactor: better naming
This commit is contained in:
parent
6198177ec6
commit
e6a281f19e
4 changed files with 6 additions and 7 deletions
|
|
@ -11,7 +11,7 @@ from pypika.dialects import MySQLQueryBuilder, PostgreSQLQueryBuilder
|
|||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.database.utils import NESTED_SET_HIERARCHY, is_pypika_function_object
|
||||
from frappe.database.utils import NestedSetHierarchy, is_pypika_function_object
|
||||
from frappe.model.db_query import get_timespan_date_range
|
||||
from frappe.query_builder import Criterion, Field, Order, Table, functions
|
||||
from frappe.query_builder.functions import Function, SqlFunctions
|
||||
|
|
@ -220,7 +220,7 @@ OPERATOR_MAP: dict[str, Callable] = {
|
|||
"between": func_between,
|
||||
"is": func_is,
|
||||
"timespan": func_timespan,
|
||||
"nested_set": NESTED_SET_HIERARCHY,
|
||||
"nested_set": NestedSetHierarchy,
|
||||
# TODO: Add support for custom operators (WIP) - via filters_config hooks
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ class Engine:
|
|||
)
|
||||
if result:
|
||||
result = list(itertools.chain.from_iterable(result))
|
||||
conditions = conditions.where(_operator(getattr(table, key), result))
|
||||
conditions = conditions.where(_operator(getattr(table, key), result))
|
||||
else:
|
||||
conditions = conditions.where(_operator(getattr(table, key), ("",)))
|
||||
# Allow additional conditions
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ QueryValues = tuple | list | dict | NoneType
|
|||
EmptyQueryValues = object()
|
||||
FallBackDateTimeStr = "0001-01-01 00:00:00.000000"
|
||||
|
||||
NESTED_SET_HIERARCHY = (
|
||||
NestedSetHierarchy = (
|
||||
"ancestors of",
|
||||
"descendants of",
|
||||
"not ancestors of",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import frappe.permissions
|
|||
import frappe.share
|
||||
from frappe import _
|
||||
from frappe.core.doctype.server_script.server_script_utils import get_server_script_map
|
||||
from frappe.database.utils import NESTED_SET_HIERARCHY, FallBackDateTimeStr
|
||||
from frappe.database.utils import FallBackDateTimeStr, NestedSetHierarchy
|
||||
from frappe.model import optional_fields
|
||||
from frappe.model.meta import get_table_columns
|
||||
from frappe.model.utils.user_settings import get_user_settings, update_user_settings
|
||||
|
|
@ -568,7 +568,7 @@ class DatabaseQuery:
|
|||
can_be_null = True
|
||||
|
||||
# prepare in condition
|
||||
if f.operator.lower() in NESTED_SET_HIERARCHY:
|
||||
if f.operator.lower() in NestedSetHierarchy:
|
||||
values = f.value or ""
|
||||
|
||||
# TODO: handle list and tuple
|
||||
|
|
|
|||
|
|
@ -254,7 +254,6 @@ class TestQuery(FrappeTestCase):
|
|||
d.update(record)
|
||||
d.insert()
|
||||
|
||||
|
||||
def test_nestedset(self):
|
||||
frappe.db.sql("delete from `tabDocType` where `name` = 'Test Tree DocType'")
|
||||
frappe.db.sql_ddl("drop table if exists `tabTest Tree DocType`")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue