MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / visit

Function visit

lib/sqlalchemy/sql/util.py:300–319  ·  view source on GitHub ↗
(element: ClauseElement)

Source from the content-addressed store, hash-verified

298 stack: List[BinaryExpression[Any]] = []
299
300 def visit(element: ClauseElement) -> Iterator[ColumnElement[Any]]:
301 if isinstance(element, ScalarSelect):
302 # we don't want to dig into correlated subqueries,
303 # those are just column elements by themselves
304 yield element
305 elif element.__visit_name__ == "binary" and operators.is_comparison(
306 element.operator # type: ignore
307 ):
308 stack.insert(0, element) # type: ignore
309 for l in visit(element.left): # type: ignore
310 for r in visit(element.right): # type: ignore
311 fn(stack[0], l, r)
312 stack.pop(0)
313 for elem in element.get_children():
314 visit(elem)
315 else:
316 if isinstance(element, ColumnClause):
317 yield element
318 for elem in element.get_children():
319 yield from visit(elem)
320
321 list(visit(expr))
322 visit = None # type: ignore # remove gc cycles

Callers 1

visit_binary_productFunction · 0.85

Calls 4

is_comparisonMethod · 0.80
insertMethod · 0.45
popMethod · 0.45
get_childrenMethod · 0.45

Tested by

no test coverage detected