From 7a25be0f4214720198029e85c2f1d18f4fc8bad3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 8 Nov 2007 00:26:23 +0000 Subject: - 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 --- test/sql/select.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/sql/select.py') 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") -- cgit v1.2.1