From deaff3e97fbb166afe7fde42700a504863bd4679 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 15 Jul 2008 15:04:43 +0000 Subject: [PATCH] - Fixed bug when calling select([literal('foo')]) or select([bindparam('foo')]). --- CHANGES | 11 +++++++++-- lib/sqlalchemy/sql/compiler.py | 2 +- test/sql/select.py | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index ead13a5309..d35f2243a7 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,9 @@ CHANGES ======= 0.5beta3 ======== + - 0.5beta3 includes all bugfixes listed under release + "0.4.7". + - orm - Added a new SessionExtension hook called after_attach(). This is called at the point of attachment for objects @@ -12,8 +15,8 @@ CHANGES 0.5beta2 ======== - - 0.5beta2 includes all bugfixes listed under release - "0.4.7". + - 0.5beta2 includes some of the bugfixes listed under + release "0.4.7". - orm - In addition to expired attributes, deferred attributes @@ -193,6 +196,10 @@ CHANGES flag is always True with a "transactional" (in 0.5 a non-"autocommit") Session. +- sql + - Fixed bug when calling select([literal('foo')]) + or select([bindparam('foo')]). + - schema - create_all(), drop_all(), create(), drop() all raise an error if the table name or schema name contains diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 05b3f550db..1edf04ee1e 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -459,7 +459,7 @@ class DefaultCompiler(engine.Compiled): column.table is not None and \ not isinstance(column.table, sql.Select): return column.label(column.name) - elif not isinstance(column, (sql._UnaryExpression, sql._TextClause)) and (not hasattr(column, 'name') or isinstance(column, sql._Function)): + elif not isinstance(column, (sql._UnaryExpression, sql._TextClause, sql._BindParamClause)) and (not hasattr(column, 'name') or isinstance(column, sql._Function)): return column.label(column.anon_label) else: return column diff --git a/test/sql/select.py b/test/sql/select.py index b6a1f7ccc6..ddd8ede42f 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -739,6 +739,9 @@ FROM mytable, myothertable WHERE foo.id = foofoo(lala) AND datetime(foo) = Today def test_literal(self): + + self.assert_compile(select([literal('foo')]), "SELECT :param_1") + self.assert_compile(select([literal("foo") + literal("bar")], from_obj=[table1]), "SELECT :param_1 || :param_2 AS anon_1 FROM mytable") -- 2.47.3