summaryrefslogtreecommitdiff
path: root/test/sql/test_query.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-06-04 20:52:30 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-06-04 20:52:30 -0400
commit09080baad1a9f910a5a406dfad9241104ccbc6d8 (patch)
tree97bdbcc41d914e83cecede45033dd91732748e77 /test/sql/test_query.py
parentc0f922116004d762991bdfe56da31d3b70e8c01d (diff)
downloadsqlalchemy-09080baad1a9f910a5a406dfad9241104ccbc6d8.tar.gz
- Adjusted the __contains__() method of
a RowProxy result row such that no exception throw is generated internally; NoSuchColumnError() also will generate its message regardless of whether or not the column construct can be coerced to a string. [ticket:2178]. Also in 0.6.8.
Diffstat (limited to 'test/sql/test_query.py')
-rw-r--r--test/sql/test_query.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index c295cd282..359123f57 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -341,6 +341,25 @@ class QueryTest(fixtures.TestBase):
assert_raises(exc.NoSuchColumnError, lambda: result[0]['fake key'])
assert_raises(exc.NoSuchColumnError, lambda: result[0][addresses.c.address_id])
+ def test_column_error_printing(self):
+ row = testing.db.execute(select([1])).first()
+ class unprintable(object):
+ def __str__(self):
+ raise ValueError("nope")
+
+ msg = r"Could not locate column in row for column '%s'"
+
+ for accessor, repl in [
+ ("x", "x"),
+ (Column("q", Integer), "q"),
+ (Column("q", Integer) + 12, r"q \+ :q_1"),
+ (unprintable(), "unprintable element.*"),
+ ]:
+ assert_raises_message(
+ exc.NoSuchColumnError,
+ msg % repl,
+ lambda: row[accessor]
+ )
@testing.requires.boolean_col_expressions