MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _entity_corresponds_to

Function _entity_corresponds_to

lib/sqlalchemy/orm/util.py:2109–2129  ·  view source on GitHub ↗

determine if 'given' corresponds to 'entity', in terms of an entity passed to Query that would match the same entity being referred to elsewhere in the query.

(
    given: _InternalEntityType[Any], entity: _InternalEntityType[Any]
)

Source from the content-addressed store, hash-verified

2107
2108
2109def _entity_corresponds_to(
2110 given: _InternalEntityType[Any], entity: _InternalEntityType[Any]
2111) -> bool:
2112 """determine if 'given' corresponds to 'entity', in terms
2113 of an entity passed to Query that would match the same entity
2114 being referred to elsewhere in the query.
2115
2116 """
2117 if insp_is_aliased_class(entity):
2118 if insp_is_aliased_class(given):
2119 if entity._base_alias() is given._base_alias():
2120 return True
2121 return False
2122 elif insp_is_aliased_class(given):
2123 if given._use_mapper_path:
2124 return entity in given.with_polymorphic_mappers
2125 else:
2126 return entity is given
2127
2128 assert insp_is_mapper(given)
2129 return entity.common_parent(given)
2130
2131
2132def _entity_corresponds_to_use_path_impl(

Callers 1

corresponds_toMethod · 0.85

Calls 3

insp_is_aliased_classFunction · 0.85
insp_is_mapperFunction · 0.85
common_parentMethod · 0.80

Tested by

no test coverage detected