diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-01-22 14:04:20 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-01-22 14:04:20 -0500 |
commit | 09a503e49724b61a8119f0b7855a990a29fc1521 (patch) | |
tree | dc2c87cc9291f31b99c2248beb42f26e0f70786d /test/sql/test_query.py | |
parent | c9a1e570ad68028e0de0551155caeae313c9c7fd (diff) | |
download | sqlalchemy-09a503e49724b61a8119f0b7855a990a29fc1521.tar.gz |
- [bug] Fixed bug whereby a table-bound Column
object named "<a>_<b>" which matched a column
labeled as "<tablename>_<colname>" could match
inappropriately when targeting in a result
set row. [ticket:2377]
- requires that we change the tuple format in RowProxy.
Makes an improvement to the cases tested against
an unpickled RowProxy as well though doesn't solve the
problem there entirely.
Diffstat (limited to 'test/sql/test_query.py')
-rw-r--r-- | test/sql/test_query.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 7f127a6ef..888eb3f96 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -307,6 +307,31 @@ class QueryTest(fixtures.TestBase): self.assert_(not (rp != equal)) self.assert_(not (equal != equal)) + @testing.provide_metadata + def test_column_label_overlap_fallback(self): + content = Table('content', self.metadata, + Column('type', String(30)), + ) + bar = Table('bar', self.metadata, + Column('content_type', String(30)) + ) + self.metadata.create_all(testing.db) + testing.db.execute(content.insert().values(type="t1")) + row = testing.db.execute(content.select(use_labels=True)).first() + assert content.c.type in row + assert bar.c.content_type not in row + assert sql.column('content_type') in row + + row = testing.db.execute(select([content.c.type.label("content_type")])).first() + assert content.c.type in row + assert bar.c.content_type not in row + assert sql.column('content_type') in row + + row = testing.db.execute(select([(content.c.type > 5).label("content_type")])).first() + assert content.c.type in row + assert bar.c.content_type not in row + assert sql.column('content_type') in row + def test_pickled_rows(self): users.insert().execute( {'user_id':7, 'user_name':'jack'}, @@ -336,7 +361,7 @@ class QueryTest(fixtures.TestBase): eq_(result[0][users.c.user_id], 7) eq_(result[0][users.c.user_name], 'jack') - if use_labels: + if not pickle or use_labels: assert_raises(exc.NoSuchColumnError, lambda: result[0][addresses.c.user_id]) else: # test with a different table. name resolution is |