MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _generate_row_adapter

Method _generate_row_adapter

lib/sqlalchemy/orm/strategies.py:2366–2443  ·  view source on GitHub ↗
(
        self,
        compile_state,
        entity,
        path,
        loadopt,
        adapter,
        column_collection,
        parentmapper,
        chained_from_outerjoin,
    )

Source from the content-addressed store, hash-verified

2364 return user_defined_adapter, adapter, add_to_collection
2365
2366 def _generate_row_adapter(
2367 self,
2368 compile_state,
2369 entity,
2370 path,
2371 loadopt,
2372 adapter,
2373 column_collection,
2374 parentmapper,
2375 chained_from_outerjoin,
2376 ):
2377 with_poly_entity = path.get(
2378 compile_state.attributes, "path_with_polymorphic", None
2379 )
2380 if with_poly_entity:
2381 to_adapt = with_poly_entity
2382 else:
2383 insp = inspect(self.entity)
2384 if insp.is_aliased_class:
2385 alt_selectable = insp.selectable
2386 else:
2387 alt_selectable = None
2388
2389 to_adapt = orm_util.AliasedClass(
2390 self.mapper,
2391 alias=(
2392 alt_selectable._anonymous_fromclause(flat=True)
2393 if alt_selectable is not None
2394 else None
2395 ),
2396 flat=True,
2397 use_mapper_path=True,
2398 )
2399
2400 to_adapt_insp = inspect(to_adapt)
2401
2402 clauses = to_adapt_insp._memo(
2403 ("joinedloader_ormadapter", self),
2404 orm_util.ORMAdapter,
2405 orm_util._TraceAdaptRole.JOINEDLOAD_MEMOIZED_ADAPTER,
2406 to_adapt_insp,
2407 equivalents=self.mapper._equivalent_columns,
2408 adapt_required=True,
2409 allow_label_resolve=False,
2410 anonymize_labels=True,
2411 )
2412
2413 assert clauses.is_aliased_class
2414
2415 innerjoin = (
2416 loadopt.local_opts.get("innerjoin", self.parent_property.innerjoin)
2417 if loadopt is not None
2418 else self.parent_property.innerjoin
2419 )
2420
2421 if not innerjoin:
2422 # if this is an outer join, all non-nested eager joins from
2423 # this path must also be outer joins

Callers 1

setup_queryMethod · 0.95

Calls 6

inspectFunction · 0.90
getMethod · 0.45
_anonymous_fromclauseMethod · 0.45
_memoMethod · 0.45
appendMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected