From be4e01c101c7e870e5becaf8627a3eb0067ea428 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 12 Nov 2021 10:03:47 +0000 Subject: [PATCH] db: Don't use legacy 'Row()' methods Resolve the following RemovedIn20Warning warnings: The Row.keys() method is considered legacy as of the 1.x series of SQLAlchemy and will be removed in 2.0. Use the namedtuple standard accessor Row._fields, or for full mapping behavior use row._mapping.keys() An additional warning that appears to have been resolved in the interim is also removed. Change-Id: I0c33130a745b986f1bcd2ec177f78e3bb68d2271 Signed-off-by: Stephen Finucane --- nova/db/main/api.py | 2 +- nova/tests/fixtures/nova.py | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/nova/db/main/api.py b/nova/db/main/api.py index c9cdbbde5b..b199a94024 100644 --- a/nova/db/main/api.py +++ b/nova/db/main/api.py @@ -600,7 +600,7 @@ def _compute_node_fetchall(context, filters=None, limit=None, marker=None): results = conn.execute(select).fetchall() # Callers expect dict-like objects, not SQLAlchemy RowProxy objects... - results = [dict(r) for r in results] + results = [dict(r._mapping) for r in results] conn.close() return results diff --git a/nova/tests/fixtures/nova.py b/nova/tests/fixtures/nova.py index 6d8cb65e68..b1f4b5bbd2 100644 --- a/nova/tests/fixtures/nova.py +++ b/nova/tests/fixtures/nova.py @@ -865,18 +865,6 @@ class WarningsFixture(fixtures.Fixture): message=r'The Column.copy\(\) method is deprecated .*', category=sqla_exc.SADeprecationWarning) - warnings.filterwarnings( - 'ignore', - module='nova', - message=r'The Row.keys\(\) method is considered legacy .*', - category=sqla_exc.SADeprecationWarning) - - warnings.filterwarnings( - 'ignore', - module='nova', - message=r'Using non-integer/slice indices on Row is deprecated .*', - category=sqla_exc.SADeprecationWarning) - warnings.filterwarnings( 'ignore', module='nova',