MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_column_property_select

Method test_column_property_select

test/orm/test_query.py:7293–7309  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7291
7292 @testing.requires.nested_aggregates
7293 def test_column_property_select(self):
7294 User = self.classes.User
7295 Address = self.classes.Address
7296
7297 mapper = inspect(User)
7298 mapper.add_property(
7299 "score",
7300 column_property(
7301 select(func.sum(Address.id))
7302 .where(Address.user_id == User.id)
7303 .scalar_subquery()
7304 ),
7305 )
7306 session = fixture_session()
7307
7308 with self._assert_bind_args(session):
7309 session.query(func.max(User.score)).scalar()
7310
7311
7312class QueryClsTest(QueryTest):

Callers

nothing calls this directly

Calls 12

_assert_bind_argsMethod · 0.95
inspectFunction · 0.90
column_propertyFunction · 0.90
selectFunction · 0.90
fixture_sessionFunction · 0.90
add_propertyMethod · 0.80
maxMethod · 0.80
scalar_subqueryMethod · 0.45
whereMethod · 0.45
sumMethod · 0.45
scalarMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected