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 <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2021-11-12 10:03:47 +00:00
parent b88ea30701
commit be4e01c101
2 changed files with 1 additions and 13 deletions

View File

@ -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

View File

@ -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',