MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_orderby_subquery

Method test_orderby_subquery

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

Source from the content-addressed store, hash-verified

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