MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / add_entity

Method add_entity

lib/sqlalchemy/orm/query.py:1333–1357  ·  view source on GitHub ↗

add a mapped entity to the list of result columns to be returned. .. seealso:: :meth:`_sql.Select.add_columns` - v2 comparable method.

(
        self,
        entity: _EntityType[Any],
        alias: Optional[Union[Alias, Subquery]] = None,
    )

Source from the content-addressed store, hash-verified

1331
1332 @_generative
1333 def add_entity(
1334 self,
1335 entity: _EntityType[Any],
1336 alias: Optional[Union[Alias, Subquery]] = None,
1337 ) -> Query[Any]:
1338 """add a mapped entity to the list of result columns
1339 to be returned.
1340
1341 .. seealso::
1342
1343 :meth:`_sql.Select.add_columns` - v2 comparable method.
1344 """
1345
1346 if alias is not None:
1347 # TODO: deprecate
1348 entity = AliasedClass(entity, alias)
1349
1350 self._raw_columns = list(self._raw_columns)
1351
1352 self._raw_columns.append(
1353 coercions.expect(
1354 roles.ColumnsClauseRole, entity, apply_propagate_attrs=self
1355 )
1356 )
1357 return self
1358
1359 @_generative
1360 def with_session(self, session: Session) -> Self:

Callers 11

test_aliased_classesMethod · 0.80
test_join_with_clearMethod · 0.80
test_join_no_clearMethod · 0.80
test_joinMethod · 0.80
test_multi_mappersMethod · 0.80
test_joinMethod · 0.80

Calls 2

AliasedClassClass · 0.85
appendMethod · 0.45

Tested by 10

test_aliased_classesMethod · 0.64
test_join_with_clearMethod · 0.64
test_join_no_clearMethod · 0.64
test_joinMethod · 0.64
test_multi_mappersMethod · 0.64
test_joinMethod · 0.64