diff options
author | Zuul <zuul@review.opendev.org> | 2021-11-12 12:20:40 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-11-12 12:20:40 +0000 |
commit | 4f462148a4cb0e43393453b712a539ce2b0d2082 (patch) | |
tree | 7b35b408ea3e1291e7b405d33f0fa9503ffe4aea | |
parent | 8360df736d377d02cb7f22e6c32c10295476086b (diff) | |
parent | 5544f1033fdbbfe7fba170c82407df0dbb78ad10 (diff) | |
download | oslo-db-4f462148a4cb0e43393453b712a539ce2b0d2082.tar.gz |
Merge "Don't use dict-style attribute accesses"
-rw-r--r-- | oslo_db/sqlalchemy/utils.py | 2 | ||||
-rw-r--r-- | oslo_db/tests/fixtures.py | 5 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_sqlalchemy.py | 2 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_utils.py | 12 |
4 files changed, 9 insertions, 12 deletions
diff --git a/oslo_db/sqlalchemy/utils.py b/oslo_db/sqlalchemy/utils.py index 99da62b..2ab7188 100644 --- a/oslo_db/sqlalchemy/utils.py +++ b/oslo_db/sqlalchemy/utils.py @@ -496,7 +496,7 @@ def drop_old_duplicate_entries_from_table(engine, table_name, is_none = None # workaround for pyflakes delete_condition &= table.c.deleted_at == is_none for name in uc_column_names: - delete_condition &= table.c[name] == row[name] + delete_condition &= table.c[name] == row._mapping[name] rows_to_delete_select = sqlalchemy.sql.select( table.c.id, diff --git a/oslo_db/tests/fixtures.py b/oslo_db/tests/fixtures.py index a1b6929..7db7b78 100644 --- a/oslo_db/tests/fixtures.py +++ b/oslo_db/tests/fixtures.py @@ -49,11 +49,6 @@ class WarningsFixture(fixtures.Fixture): warnings.filterwarnings( 'once', - message=r'Using non-integer/slice indices on Row is deprecated .*', - category=sqla_exc.SADeprecationWarning) - - warnings.filterwarnings( - 'once', message=r'The Engine.execute\(\) method is considered legacy .*', category=sqla_exc.SADeprecationWarning) diff --git a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py index 10def6b..ede67c6 100644 --- a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py +++ b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py @@ -327,7 +327,7 @@ class MySQLModeTestCase(db_test_base._MySQLOpportunisticTestCase): self.connection.execute(self.test_table.insert(), bar=value) result = self.connection.execute(self.test_table.select()) - return result.fetchone()['bar'] + return result.fetchone().bar def test_string_too_long(self): value = 'a' * 512 diff --git a/oslo_db/tests/sqlalchemy/test_utils.py b/oslo_db/tests/sqlalchemy/test_utils.py index 7531332..2f61004 100644 --- a/oslo_db/tests/sqlalchemy/test_utils.py +++ b/oslo_db/tests/sqlalchemy/test_utils.py @@ -761,17 +761,19 @@ class TestMigrationUtils(db_test_base._DbTestCase): base_select = table.select() rows_select = base_select.where(table.c.deleted != table.c.id) - row_ids = [row['id'] for row in - self.engine.execute(rows_select).fetchall()] + row_ids = [ + row.id for row in self.engine.execute(rows_select).fetchall() + ] self.assertEqual(len(expected_values), len(row_ids)) for value in expected_values: self.assertIn(value['id'], row_ids) deleted_rows_select = base_select.where( table.c.deleted == table.c.id) - deleted_rows_ids = [row['id'] for row in - self.engine.execute( - deleted_rows_select).fetchall()] + deleted_rows_ids = [ + row.id for row in + self.engine.execute(deleted_rows_select).fetchall() + ] self.assertEqual(len(values) - len(row_ids), len(deleted_rows_ids)) for value in soft_deleted_values: |