diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-05 14:22:55 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-05 14:22:55 -0500 |
| commit | a4e3bc61bcb1f1aeaa334f6da4f3b9fcb3059d00 (patch) | |
| tree | a1c1e25d24e6a65c7a368a85125818975f28c59a /test/sql/test_query.py | |
| parent | e0ec05366f7363edd1873c4d095e11151cdd4dff (diff) | |
| download | sqlalchemy-a4e3bc61bcb1f1aeaa334f6da4f3b9fcb3059d00.tar.gz | |
- [bug] A significant change to how labeling
is applied to columns in SELECT statements
allows "truncated" labels, that is label names
that are generated in Python which exceed
the maximum identifier length (note this is
configurable via label_length on create_engine()),
to be properly referenced when rendered inside
of a subquery, as well as to be present
in a result set row using their original
in-Python names. [ticket:2396]
- apply pep8 to test_labels
Diffstat (limited to 'test/sql/test_query.py')
| -rw-r--r-- | test/sql/test_query.py | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 9725d3d3a..f9ec82a6a 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -1094,12 +1094,16 @@ class PercentSchemaNamesTest(fixtures.TestBase): @classmethod def setup_class(cls): - global percent_table, metadata + global percent_table, metadata, lightweight_percent_table metadata = MetaData(testing.db) percent_table = Table('percent%table', metadata, Column("percent%", Integer), Column("spaces % more spaces", Integer), ) + lightweight_percent_table = sql.table('percent%table', + sql.column("percent%"), + sql.column("spaces % more spaces"), + ) metadata.create_all() def teardown(self): @@ -1109,7 +1113,8 @@ class PercentSchemaNamesTest(fixtures.TestBase): def teardown_class(cls): metadata.drop_all() - @testing.skip_if(lambda: testing.against('postgresql'), "psycopg2 2.4 no longer accepts % in bind placeholders") + @testing.skip_if(lambda: testing.against('postgresql'), + "psycopg2 2.4 no longer accepts % in bind placeholders") def test_single_roundtrip(self): percent_table.insert().execute( {'percent%':5, 'spaces % more spaces':12}, @@ -1125,8 +1130,10 @@ class PercentSchemaNamesTest(fixtures.TestBase): ) self._assert_table() - @testing.skip_if(lambda: testing.against('postgresql'), "psycopg2 2.4 no longer accepts % in bind placeholders") - @testing.crashes('mysql+mysqldb', 'MySQLdb handles executemany() inconsistently vs. execute()') + @testing.skip_if(lambda: testing.against('postgresql'), + "psycopg2 2.4 no longer accepts % in bind placeholders") + @testing.crashes('mysql+mysqldb', "MySQLdb handles executemany() " + "inconsistently vs. execute()") def test_executemany_roundtrip(self): percent_table.insert().execute( {'percent%':5, 'spaces % more spaces':12}, @@ -1139,9 +1146,17 @@ class PercentSchemaNamesTest(fixtures.TestBase): self._assert_table() def _assert_table(self): - for table in (percent_table, percent_table.alias()): + for table in ( + percent_table, + percent_table.alias(), + lightweight_percent_table, + lightweight_percent_table.alias()): eq_( - table.select().order_by(table.c['percent%']).execute().fetchall(), + list( + testing.db.execute( + table.select().order_by(table.c['percent%']) + ) + ), [ (5, 12), (7, 11), @@ -1151,28 +1166,39 @@ class PercentSchemaNamesTest(fixtures.TestBase): ) eq_( - table.select(). - where(table.c['spaces % more spaces'].in_([9, 10])). - order_by(table.c['percent%']).execute().fetchall(), + list( + testing.db.execute( + table.select(). + where(table.c['spaces % more spaces'].in_([9, 10])). + order_by(table.c['percent%']), + ) + ), [ (9, 10), (11, 9) ] ) - result = table.select().order_by(table.c['percent%']).execute() - row = result.fetchone() + row = testing.db.execute(table.select().\ + order_by(table.c['percent%'])).first() + eq_(row['percent%'], 5) + eq_(row['spaces % more spaces'], 12) + eq_(row[table.c['percent%']], 5) eq_(row[table.c['spaces % more spaces']], 12) - row = result.fetchone() - eq_(row['percent%'], 7) - eq_(row['spaces % more spaces'], 11) - result.close() - percent_table.update().values({percent_table.c['spaces % more spaces']:15}).execute() + percent_table.update().values( + {percent_table.c['spaces % more spaces']:15} + ).execute() eq_( - percent_table.select().order_by(percent_table.c['percent%']).execute().fetchall(), + list( + testing.db.execute( + percent_table.\ + select().\ + order_by(percent_table.c['percent%']) + ) + ), [ (5, 15), (7, 15), |
