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

Function find_join_source

lib/sqlalchemy/sql/util.py:130–155  ·  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

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