MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _entity_namespace

Function _entity_namespace

lib/sqlalchemy/sql/base.py:2587–2603  ·  view source on GitHub ↗

Return the nearest .entity_namespace for the given entity. If not immediately available, does an iterate to find a sub-element that has one, if any.

(
    entity: Union[_HasEntityNamespace, ExternallyTraversible],
)

Source from the content-addressed store, hash-verified

2585
2586
2587def _entity_namespace(
2588 entity: Union[_HasEntityNamespace, ExternallyTraversible],
2589) -> _EntityNamespace:
2590 """Return the nearest .entity_namespace for the given entity.
2591
2592 If not immediately available, does an iterate to find a sub-element
2593 that has one, if any.
2594
2595 """
2596 try:
2597 return cast(_HasEntityNamespace, entity).entity_namespace
2598 except AttributeError:
2599 for elem in visitors.iterate(cast(ExternallyTraversible, entity)):
2600 if _is_has_entity_namespace(elem):
2601 return elem.entity_namespace
2602 else:
2603 raise
2604
2605
2606@overload

Callers 3

_entity_namespace_keyFunction · 0.85
entity_namespaceMethod · 0.85

Calls 3

_is_has_entity_namespaceFunction · 0.85
iterateMethod · 0.80
castFunction · 0.70

Tested by

no test coverage detected