From cef652a2d612ecbf078d57fbf81abef21a18b631 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 21 Mar 2007 20:43:34 +0000 Subject: - slightly better support for bind params as column clauses, either via bindparam() or via literal(), i.e. select([literal('foo')]) - removed "table" argument from column(). this does not add the column to the table anyway so was misleading. - Select _exportable_columns() only exports Selectable instances - Select uses _exportable_columns() when searching for engines instead of _raw_columns for similar reasons (non selectables have no engine) - _BindParamClause no longer has a _make_proxy(). its not a ColumnElement. - _Label detects underlying column element and will generate its own column()._make_proxy() if the element is not a ColumnElement. this allows a Label to be declared for nearly anything and it can export itself as a column on a containing Selectable. --- test/sql/select.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/sql') diff --git a/test/sql/select.py b/test/sql/select.py index b6f769959..1ca8224a8 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -678,6 +678,13 @@ myothertable.othername != :myothertable_othername AND EXISTS (select yay from fo c = s.compile(parameters = {'test' : 7}) self.assert_(c.get_params() == {'test' : 7}) + def testbindascol(self): + t = table('foo', column('id')) + + s = select([t, literal('lala').label('hoho')]) + self.runtest(s, "SELECT foo.id, :literal AS hoho FROM foo") + assert [str(c) for c in s.c] == ["id", "hoho"] + def testin(self): self.runtest(select([table1], table1.c.myid.in_(1, 2, 3)), "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid IN (:mytable_myid, :mytable_my_1, :mytable_my_2)") -- cgit v1.2.1