diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-30 17:27:53 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-03-30 17:27:53 -0400 |
| commit | dd20f56bc9a32f0c3afc545ed519dce8b028792c (patch) | |
| tree | 698d70dc7613979599910edb0b2815d98acbea6f /test | |
| parent | 4df1e07bb9c43ed8d1927a90c75f3142beaa403a (diff) | |
| download | sqlalchemy-dd20f56bc9a32f0c3afc545ed519dce8b028792c.tar.gz | |
- make sure negative row indexes are based on the size of the
number of columns we're actually reporting on
- add more tests for negative row index
- changelog/migration
Diffstat (limited to 'test')
| -rw-r--r-- | test/engine/test_execute.py | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index aadd170f3..66903bef3 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -951,24 +951,32 @@ class ResultProxyTest(fixtures.TestBase): {'key': (None, None, 0), 0: (None, None, 0)}) assert isinstance(row, collections.Sequence) - def test_rowproxy_getitem(self): - metadata = MetaData() - metadata.bind = 'sqlite://' - values = Table('users', metadata, + @testing.provide_metadata + def test_rowproxy_getitem_indexes_compiled(self): + values = Table('users', self.metadata, Column('key', String(10), primary_key=True), Column('value', String(10))) values.create() - values.insert().execute(key='One', value='Uno') - row = values.select().execute().fetchone() - - assert row['key'] == 'One' - assert row['value'] == 'Uno' - assert row[0] == 'One' - assert row[1] == 'Uno' - assert row[-2] == 'One' - assert row[-1] == 'Uno' - assert row[1:0:-1] == ('Uno',) + testing.db.execute(values.insert(), dict(key='One', value='Uno')) + row = testing.db.execute(values.select()).first() + eq_(row['key'], 'One') + eq_(row['value'], 'Uno') + eq_(row[0], 'One') + eq_(row[1], 'Uno') + eq_(row[-2], 'One') + eq_(row[-1], 'Uno') + eq_(row[1:0:-1], ('Uno',)) + + def test_rowproxy_getitem_indexes_raw(self): + row = testing.db.execute("select 'One' as key, 'Uno' as value").first() + eq_(row['key'], 'One') + eq_(row['value'], 'Uno') + eq_(row[0], 'One') + eq_(row[1], 'Uno') + eq_(row[-2], 'One') + eq_(row[-1], 'Uno') + eq_(row[1:0:-1], ('Uno',)) @testing.requires.cextensions def test_row_c_sequence_check(self): |
