diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-21 16:12:37 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-21 16:12:37 +0000 |
| commit | 0983b610b47d2cbe502837ded365a2d2dbcdc883 (patch) | |
| tree | a43a8311554a871cefa6f691dc5a3b62f463997b /test/sql/select.py | |
| parent | 3ecf84f5adb428f814cd18b47ac65d133112cbf0 (diff) | |
| download | sqlalchemy-0983b610b47d2cbe502837ded365a2d2dbcdc883.tar.gz | |
- An alias() of a select() will convert to a "scalar subquery"
when used in an unambiguously scalar context, i.e. it's used
in a comparison operation. This applies to
the ORM when using query.subquery() as well.
Diffstat (limited to 'test/sql/select.py')
| -rw-r--r-- | test/sql/select.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py index aeb53bf19..5d6d6dcaa 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -307,6 +307,12 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A s = select([table1.c.myid]).correlate(None).as_scalar() self.assert_compile(select([table1, s]), "SELECT mytable.myid, mytable.name, mytable.description, (SELECT mytable.myid FROM mytable) AS anon_1 FROM mytable") + # test that aliases use as_scalar() when used in an explicitly scalar context + s = select([table1.c.myid]).alias() + self.assert_compile(select([table1.c.myid]).where(table1.c.myid==s), "SELECT mytable.myid FROM mytable WHERE mytable.myid = (SELECT mytable.myid FROM mytable)") + self.assert_compile(select([table1.c.myid]).where(s > table1.c.myid), "SELECT mytable.myid FROM mytable WHERE mytable.myid < (SELECT mytable.myid FROM mytable)") + + s = select([table1.c.myid]).as_scalar() self.assert_compile(select([table2, s]), "SELECT myothertable.otherid, myothertable.othername, (SELECT mytable.myid FROM mytable) AS anon_1 FROM myothertable") |
