| 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 = ( |