From: Mike Bayer Date: Tue, 15 Jul 2008 15:07:00 +0000 (+0000) Subject: merged select([literal('foo')]) fix from trunk r4933 X-Git-Tag: rel_0_4_7~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5a1836796d5b0a73ca65e0c4b5f0fc947f6f20b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git merged select([literal('foo')]) fix from trunk r4933 --- diff --git a/CHANGES b/CHANGES index 603aa57823..ebc85b4297 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ ======= CHANGES ======= + 0.4.7 ===== - orm @@ -30,6 +31,10 @@ CHANGES - Removed erroneous 'self' reference when raising UnmappedColumnError during flush() operation. +- 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 408d24c278..76877aded4 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -461,7 +461,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 bea8621121..82795d0199 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -729,6 +729,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")