summaryrefslogtreecommitdiff
path: root/test/sql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-09-02 11:48:15 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-09-02 11:48:15 -0400
commit9a6947427af58eeb6ebf09ec6de2a1b7ec12d828 (patch)
tree963379c329e48e7dfb82ef49a3a24bc514ffb254 /test/sql/test_compiler.py
parentf6022839c29f7f96cb9d279aaf2e44e81cafb661 (diff)
downloadsqlalchemy-9a6947427af58eeb6ebf09ec6de2a1b7ec12d828.tar.gz
Allow stringify compiler to render unnamed column
Stringify of expression with unnamed :class:`.Column` objects, as occurs in lots of situations including ORM error reporting, will now render the name in string context as "<name unknown>" rather than raising a compile error. Change-Id: I76f637c5eb4cfdb1b526964cb001565b97e296da Fixes: #3789
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r--test/sql/test_compiler.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index a0db9864e..6896c9857 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -2432,14 +2432,16 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
assert_raises_message(
exc.CompileError,
"Cannot compile Column object until its 'name' is assigned.",
- str, sel2
+ sel2.compile,
+ dialect=default.DefaultDialect()
)
sel3 = select([my_str]).as_scalar()
assert_raises_message(
exc.CompileError,
"Cannot compile Column object until its 'name' is assigned.",
- str, sel3
+ sel3.compile,
+ dialect=default.DefaultDialect()
)
my_str.name = 'foo'
@@ -2709,6 +2711,13 @@ class StringifySpecialTest(fixtures.TestBase):
"FROM mytable WHERE mytable.myid = :myid_1"
)
+ def test_unnamed_column(self):
+ stmt = Column(Integer) == 5
+ eq_ignore_whitespace(
+ str(stmt),
+ '"<name unknown>" = :param_1'
+ )
+
def test_cte(self):
# stringify of these was supported anyway by defaultdialect.
stmt = select([table1.c.myid]).cte()