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

Method test_orderby_subquery

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

Source from the content-addressed store, hash-verified

1446 )
1447
1448 def test_orderby_subquery(self):
1449 self.assert_compile(
1450 table1.select().order_by(
1451 select(table2.c.otherid)
1452 .where(table1.c.myid == table2.c.otherid)
1453 .scalar_subquery()
1454 ),
1455 "SELECT mytable.myid, mytable.name, "
1456 "mytable.description FROM mytable ORDER BY "
1457 "(SELECT myothertable.otherid FROM "
1458 "myothertable WHERE mytable.myid = "
1459 "myothertable.otherid)",
1460 )
1461 self.assert_compile(
1462 table1.select().order_by(
1463 desc(
1464 select(table2.c.otherid)
1465 .where(table1.c.myid == table2.c.otherid)
1466 .scalar_subquery()
1467 )
1468 ),
1469 "SELECT mytable.myid, mytable.name, "
1470 "mytable.description FROM mytable ORDER BY "
1471 "(SELECT myothertable.otherid FROM "
1472 "myothertable WHERE mytable.myid = "
1473 "myothertable.otherid) DESC",
1474 )
1475
1476 def test_scalar_select(self):
1477 s = select(table1.c.myid).correlate(None).scalar_subquery()

Callers

nothing calls this directly

Calls 7

selectFunction · 0.90
descFunction · 0.90
assert_compileMethod · 0.80
order_byMethod · 0.45
selectMethod · 0.45
scalar_subqueryMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected