MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / setup_query

Method setup_query

lib/sqlalchemy/orm/strategies.py:2156–2282  ·  view source on GitHub ↗

Add a left outer join to the statement that's being constructed.

(
        self,
        compile_state,
        query_entity,
        path,
        loadopt,
        adapter,
        column_collection=None,
        parentmapper=None,
        chained_from_outerjoin=False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

2154 ).init_class_attribute(mapper)
2155
2156 def setup_query(
2157 self,
2158 compile_state,
2159 query_entity,
2160 path,
2161 loadopt,
2162 adapter,
2163 column_collection=None,
2164 parentmapper=None,
2165 chained_from_outerjoin=False,
2166 **kwargs,
2167 ):
2168 """Add a left outer join to the statement that's being constructed."""
2169
2170 if not compile_state.compile_options._enable_eagerloads:
2171 return
2172 elif (
2173 loadopt
2174 and compile_state.statement is not None
2175 and compile_state.statement.is_dml
2176 ):
2177 util.warn_deprecated(
2178 "The joinedload loader option is not compatible with DML "
2179 "statements such as INSERT, UPDATE. Only SELECT may be used."
2180 "This warning will become an exception in a future release.",
2181 "2.0",
2182 )
2183 elif self.uselist:
2184 compile_state.multi_row_eager_loaders = True
2185
2186 path = path[self.parent_property]
2187
2188 user_defined_adapter = (
2189 self._init_user_defined_eager_proc(
2190 loadopt, compile_state, compile_state.attributes
2191 )
2192 if loadopt
2193 else False
2194 )
2195
2196 if user_defined_adapter is not False:
2197 # setup an adapter but dont create any JOIN, assume it's already
2198 # in the query
2199 (
2200 clauses,
2201 adapter,
2202 add_to_collection,
2203 ) = self._setup_query_on_user_defined_adapter(
2204 compile_state,
2205 query_entity,
2206 path,
2207 adapter,
2208 user_defined_adapter,
2209 )
2210
2211 # don't do "wrap" for multi-row, we want to wrap
2212 # limited/distinct SELECT,
2213 # because we want to put the JOIN on the outside.

Callers

nothing calls this directly

Calls 8

_generate_row_adapterMethod · 0.95
inspectFunction · 0.90
contains_mapperMethod · 0.80
containsMethod · 0.45
getMethod · 0.45
intersectionMethod · 0.45

Tested by

no test coverage detected