diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-07-15 15:07:00 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-07-15 15:07:00 +0000 |
commit | a5a1836796d5b0a73ca65e0c4b5f0fc947f6f20b (patch) | |
tree | da90e9d10f98baf98b4792cfbc6eaa338b018e32 | |
parent | 89a67563ea7009447d875071c7e06a96d42b16ad (diff) | |
download | sqlalchemy-a5a1836796d5b0a73ca65e0c4b5f0fc947f6f20b.tar.gz |
merged select([literal('foo')]) fix from trunk r4933
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 2 | ||||
-rw-r--r-- | test/sql/select.py | 3 |
3 files changed, 9 insertions, 1 deletions
@@ -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 408d24c27..76877aded 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 bea862112..82795d019 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") |