MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / find_join_source

Function find_join_source

lib/sqlalchemy/sql/util.py:131–156  ·  view source on GitHub ↗

Given a list of FROM clauses and a selectable, return the first index and element from the list of clauses which can be joined against the selectable. returns None, None if no match is found. e.g.:: clause1 = table1.join(table2) clause2 = table4.join(table5)

(
    clauses: List[FromClause], join_to: FromClause
)

Source from the content-addressed store, hash-verified

129
130
131def find_join_source(
132 clauses: List[FromClause], join_to: FromClause
133) -> List[int]:
134 """Given a list of FROM clauses and a selectable,
135 return the first index and element from the list of
136 clauses which can be joined against the selectable. returns
137 None, None if no match is found.
138
139 e.g.::
140
141 clause1 = table1.join(table2)
142 clause2 = table4.join(table5)
143
144 join_to = table2.join(table3)
145
146 find_join_source([clause1, clause2], join_to) == clause1
147
148 """
149
150 selectables = list(_from_objects(join_to))
151 idx = []
152 for i, f in enumerate(clauses):
153 for s in selectables:
154 if f.is_derived_from(s):
155 idx.append(i)
156 return idx
157
158
159def find_left_clause_that_matches_given(

Callers

nothing calls this directly

Calls 3

_from_objectsFunction · 0.85
is_derived_fromMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected