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

Method setup_query

lib/sqlalchemy/orm/strategies.py:2140–2266  ·  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

2138 ).init_class_attribute(mapper)
2139
2140 def setup_query(
2141 self,
2142 compile_state,
2143 query_entity,
2144 path,
2145 loadopt,
2146 adapter,
2147 column_collection=None,
2148 parentmapper=None,
2149 chained_from_outerjoin=False,
2150 **kwargs,
2151 ):
2152 """Add a left outer join to the statement that's being constructed."""
2153
2154 if not compile_state.compile_options._enable_eagerloads:
2155 return
2156 elif (
2157 loadopt
2158 and compile_state.statement is not None
2159 and compile_state.statement.is_dml
2160 ):
2161 util.warn_deprecated(
2162 "The joinedload loader option is not compatible with DML "
2163 "statements such as INSERT, UPDATE. Only SELECT may be used."
2164 "This warning will become an exception in a future release.",
2165 "2.0",
2166 )
2167 elif self.uselist:
2168 compile_state.multi_row_eager_loaders = True
2169
2170 path = path[self.parent_property]
2171
2172 user_defined_adapter = (
2173 self._init_user_defined_eager_proc(
2174 loadopt, compile_state, compile_state.attributes
2175 )
2176 if loadopt
2177 else False
2178 )
2179
2180 if user_defined_adapter is not False:
2181 # setup an adapter but dont create any JOIN, assume it's already
2182 # in the query
2183 (
2184 clauses,
2185 adapter,
2186 add_to_collection,
2187 ) = self._setup_query_on_user_defined_adapter(
2188 compile_state,
2189 query_entity,
2190 path,
2191 adapter,
2192 user_defined_adapter,
2193 )
2194
2195 # don't do "wrap" for multi-row, we want to wrap
2196 # limited/distinct SELECT,
2197 # 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