MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _process

Method _process

lib/sqlalchemy/orm/strategy_options.py:1422–1481  ·  view source on GitHub ↗
(self, compile_state, mapper_entities, raiseerr)

Source from the content-addressed store, hash-verified

1420 parent.context += (loader,)
1421
1422 def _process(self, compile_state, mapper_entities, raiseerr):
1423 is_refresh = compile_state.compile_options._for_refresh_state
1424
1425 if is_refresh and not self.propagate_to_loaders:
1426 return
1427
1428 entities = [ent.entity_zero for ent in mapper_entities]
1429 current_path = compile_state.current_path
1430
1431 start_path: _PathRepresentation = self.path
1432
1433 if current_path:
1434 # TODO: no cases in test suite where we actually get
1435 # None back here
1436 new_path = self._chop_path(start_path, current_path)
1437 if new_path is None:
1438 return
1439
1440 # chop_path does not actually "chop" a wildcard token path,
1441 # just returns it
1442 assert new_path == start_path
1443
1444 # start_path is a single-token tuple
1445 assert start_path and len(start_path) == 1
1446
1447 token = start_path[0]
1448 assert isinstance(token, str)
1449 entity = self._find_entity_basestring(entities, token, raiseerr)
1450
1451 if not entity:
1452 return
1453
1454 path_element = entity
1455
1456 # transfer our entity-less state into a Load() object
1457 # with a real entity path. Start with the lead entity
1458 # we just located, then go through the rest of our path
1459 # tokens and populate into the Load().
1460
1461 assert isinstance(token, str)
1462 loader = _TokenStrategyLoad.create(
1463 path_element._path_registry,
1464 token,
1465 self.strategy,
1466 None,
1467 self.local_opts,
1468 self.propagate_to_loaders,
1469 raiseerr=raiseerr,
1470 )
1471 if not loader:
1472 return
1473
1474 assert loader.path.is_token
1475
1476 # don't pass a reconciled lead entity here
1477 loader.process_compile_state(
1478 self, compile_state, mapper_entities, None, raiseerr
1479 )

Callers

nothing calls this directly

Calls 4

_chop_pathMethod · 0.80
createMethod · 0.45
process_compile_stateMethod · 0.45

Tested by

no test coverage detected