MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_cols_future

Method test_cols_future

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

Source from the content-addressed store, hash-verified

4564 eq_(q.distinct().count(), 3)
4565
4566 def test_cols_future(self):
4567 User, Address = self.classes.User, self.classes.Address
4568
4569 s = fixture_session()
4570
4571 stmt = select(func.count(distinct(User.name)))
4572 eq_(
4573 s.scalar(select(func.count()).select_from(stmt.subquery())),
4574 1,
4575 )
4576
4577 stmt = select(func.count(distinct(User.name))).distinct()
4578
4579 eq_(
4580 s.scalar(select(func.count()).select_from(stmt.subquery())),
4581 1,
4582 )
4583
4584 stmt = select(User.name)
4585 eq_(
4586 s.scalar(select(func.count()).select_from(stmt.subquery())),
4587 4,
4588 )
4589
4590 stmt = select(User.name, Address).join(Address, true())
4591 eq_(
4592 s.scalar(select(func.count()).select_from(stmt.subquery())),
4593 20,
4594 )
4595
4596 stmt = select(Address.user_id)
4597 eq_(
4598 s.scalar(select(func.count()).select_from(stmt.subquery())),
4599 5,
4600 )
4601
4602 stmt = stmt.distinct()
4603 eq_(
4604 s.scalar(select(func.count()).select_from(stmt.subquery())),
4605 3,
4606 )
4607
4608
4609class DistinctTest(QueryTest, AssertsCompiledSQL):

Callers

nothing calls this directly

Calls 11

fixture_sessionFunction · 0.90
selectFunction · 0.90
distinctFunction · 0.90
eq_Function · 0.90
trueFunction · 0.90
countMethod · 0.45
scalarMethod · 0.45
select_fromMethod · 0.45
subqueryMethod · 0.45
distinctMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected