MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _merge_with

Method _merge_with

lib/sqlalchemy/orm/util.py:1166–1194  ·  view source on GitHub ↗
(self, other: AliasedInsp[_O])

Source from the content-addressed store, hash-verified

1164 )
1165
1166 def _merge_with(self, other: AliasedInsp[_O]) -> AliasedInsp[_O]:
1167 # assert self._is_with_polymorphic
1168 # assert other._is_with_polymorphic
1169
1170 primary_mapper = other.mapper
1171
1172 assert self.mapper is primary_mapper
1173
1174 our_classes = util.to_set(
1175 mp.class_ for mp in self.with_polymorphic_mappers
1176 )
1177 new_classes = {mp.class_ for mp in other.with_polymorphic_mappers}
1178 if our_classes == new_classes:
1179 return other
1180 else:
1181 classes = our_classes.union(new_classes)
1182
1183 mappers, selectable = primary_mapper._with_polymorphic_args(
1184 classes, None, innerjoin=not other.represents_outer_join
1185 )
1186 selectable = selectable._anonymous_fromclause(flat=True)
1187 return AliasedClass(
1188 primary_mapper,
1189 selectable,
1190 with_polymorphic_mappers=mappers,
1191 with_polymorphic_discriminator=other.polymorphic_on,
1192 use_mapper_path=other._use_mapper_path,
1193 represents_outer_join=other.represents_outer_join,
1194 )._aliased_insp
1195
1196 def _adapt_element(
1197 self, expr: _ORMCOLEXPR, key: Optional[str] = None

Callers 1

_set_of_type_infoMethod · 0.80

Calls 5

AliasedClassClass · 0.85
to_setMethod · 0.80
unionMethod · 0.45
_anonymous_fromclauseMethod · 0.45

Tested by

no test coverage detected