MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_exists_method

Method test_exists_method

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

Source from the content-addressed store, hash-verified

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