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

Method test_scalar_select

test/sql/test_roles.py:422–471  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

420 is_true(coerced.compare(stmt.scalar_subquery().label(None)))
421
422 def test_scalar_select(self):
423 with testing.expect_warnings(
424 "implicitly coercing SELECT object to scalar subquery"
425 ):
426 self.assert_compile(
427 func.coalesce(select(self.table1.c.myid)),
428 "coalesce((SELECT mytable.myid FROM mytable))",
429 )
430
431 with testing.expect_warnings(
432 "implicitly coercing SELECT object to scalar subquery"
433 ):
434 s = select(self.table1.c.myid).alias()
435 self.assert_compile(
436 select(self.table1.c.myid).where(self.table1.c.myid == s),
437 "SELECT mytable.myid FROM mytable WHERE "
438 "mytable.myid = (SELECT mytable.myid FROM "
439 "mytable)",
440 )
441
442 with testing.expect_warnings(
443 "implicitly coercing SELECT object to scalar subquery"
444 ):
445 self.assert_compile(
446 select(self.table1.c.myid).where(s > self.table1.c.myid),
447 "SELECT mytable.myid FROM mytable WHERE "
448 "mytable.myid < (SELECT mytable.myid FROM "
449 "mytable)",
450 )
451
452 with testing.expect_warnings(
453 "implicitly coercing SELECT object to scalar subquery"
454 ):
455 s = select(self.table1.c.myid).alias()
456 self.assert_compile(
457 select(self.table1.c.myid).where(self.table1.c.myid == s),
458 "SELECT mytable.myid FROM mytable WHERE "
459 "mytable.myid = (SELECT mytable.myid FROM "
460 "mytable)",
461 )
462
463 with testing.expect_warnings(
464 "implicitly coercing SELECT object to scalar subquery"
465 ):
466 self.assert_compile(
467 select(self.table1.c.myid).where(s > self.table1.c.myid),
468 "SELECT mytable.myid FROM mytable WHERE "
469 "mytable.myid < (SELECT mytable.myid FROM "
470 "mytable)",
471 )
472
473 @testing.fixture()
474 def update_from_fixture(self):

Callers

nothing calls this directly

Calls 5

selectFunction · 0.90
assert_compileMethod · 0.80
coalesceMethod · 0.80
aliasMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected