diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-08 00:26:23 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-08 00:26:23 +0000 |
| commit | 7a25be0f4214720198029e85c2f1d18f4fc8bad3 (patch) | |
| tree | a7036d2b53881c858e75cd0229e712798989ef53 /test/sql/select.py | |
| parent | 004345d7c9add3647fa9b04b5c8c8c6c77be3173 (diff) | |
| download | sqlalchemy-7a25be0f4214720198029e85c2f1d18f4fc8bad3.tar.gz | |
- identified some cases where Alias needs to be cloned; but still cant clone
when its an alias of a Table; added some test coverage for one particular
case from the doctests
- fixed "having" example in doctests, updated eager load example
Diffstat (limited to 'test/sql/select.py')
| -rw-r--r-- | test/sql/select.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py index 678085fc1..1315b47ba 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -701,7 +701,33 @@ FROM mytable, myothertable WHERE foo.id = foofoo(lala) AND datetime(foo) = Today assert False except AttributeError: assert True + + def test_functions_with_cols(self): + from sqlalchemy.sql import column + users = table('users', column('id'), column('name'), column('fullname')) + calculate = select([column('q'), column('z'), column('r')], + from_obj=[func.calculate(bindparam('x'), bindparam('y'))]) + self.assert_compile(select([users], users.c.id > calculate.c.z), + "SELECT users.id, users.name, users.fullname " + "FROM users, (SELECT q, z, r " + "FROM calculate(:x, :y)) " + "WHERE users.id > z" + ) + + print "--------------------------------------------------" + s = select([users], users.c.id.between( + calculate.alias('c1').unique_params(x=17, y=45).c.z, + calculate.alias('c2').unique_params(x=5, y=12).c.z)) + + self.assert_compile(s, + "SELECT users.id, users.name, users.fullname " + "FROM users, (SELECT q, z, r " + "FROM calculate(:x, :y)) AS c1, (SELECT q, z, r " + "FROM calculate(:x_1, :y_1)) AS c2 " + "WHERE users.id BETWEEN c1.z AND c2.z" + , checkparams={'y': 45, 'x': 17, 'y_1': 12, 'x_1': 5}) + def testextract(self): """test the EXTRACT function""" self.assert_compile(select([extract("month", table3.c.otherstuff)]), "SELECT extract(month FROM thirdtable.otherstuff) FROM thirdtable") |
