MCPcopy Create free account
hub / github.com/dataease/SQLBot / transTreeToWhere

Function transTreeToWhere

backend/apps/datasource/crud/row_permission.py:27–44  ·  view source on GitHub ↗
(session: SessionDep, current_user: CurrentUser, tree: any, ds: CoreDatasource)

Source from the content-addressed store, hash-verified

25
26
27def transTreeToWhere(session: SessionDep, current_user: CurrentUser, tree: any, ds: CoreDatasource) -> str | None:
28 if tree is None:
29 return None
30 logic = tree['logic']
31
32 items = tree['items']
33 list: List[str] = []
34 if items is not None:
35 for item in items:
36 exp: str = None
37 if item['type'] == 'item':
38 exp = transTreeItem(session, current_user, item, ds)
39 elif item['type'] == 'tree':
40 exp = transTreeToWhere(session, current_user, item['sub_tree'], ds)
41
42 if exp is not None:
43 list.append(exp)
44 return '(' + f' {logic} '.join(list) + ')' if len(list) > 0 else None
45
46
47def transTreeItem(session: SessionDep, current_user: CurrentUser, item: Dict, ds: CoreDatasource) -> str | None:

Callers 1

transFilterTreeFunction · 0.85

Calls 2

transTreeItemFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected