MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit

Function visit

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

Source from the content-addressed store, hash-verified

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