MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_exists_method

Method test_exists_method

test/sql/test_compiler.py:1344–1361  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1342 )
1343
1344 def test_exists_method(self):
1345 subq = (
1346 select(func.count(table2.c.otherid))
1347 .where(table2.c.otherid == table1.c.myid)
1348 .correlate(table1)
1349 .group_by(table2.c.otherid)
1350 .having(func.count(table2.c.otherid) > 1)
1351 .exists()
1352 )
1353
1354 self.assert_compile(
1355 table1.select().where(subq),
1356 "SELECT mytable.myid, mytable.name, mytable.description "
1357 "FROM mytable WHERE EXISTS (SELECT count(myothertable.otherid) "
1358 "AS count_1 FROM myothertable WHERE myothertable.otherid = "
1359 "mytable.myid GROUP BY myothertable.otherid "
1360 "HAVING count(myothertable.otherid) > :count_2)",
1361 )
1362
1363 def test_where_subquery(self):
1364 s = (

Callers

nothing calls this directly

Calls 9

selectFunction · 0.90
assert_compileMethod · 0.80
existsMethod · 0.45
havingMethod · 0.45
group_byMethod · 0.45
correlateMethod · 0.45
whereMethod · 0.45
countMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected