db: Use Row, not LegacyRow

We added this check in change I8b845a29fa21f4ca8340d91bf5c6394094c6ab97
("db: Remove use of non-integer/slice indices") because we were using
the same code to handle two different types of object in the same
method. However, while the functions being called to generate this
function return a LegacyRow in recent versions of SQLAlchemy, it seems
older versions return a Row. The former is a subclass of the latter so
we can use the latter for both. This is also a better idea long-term,
since SQLAlchemy 2.0 removes LegacyRow.

Change-Id: Ia30c03b3878d80550cefd39271e315065f1a199d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2022-02-08 12:57:56 +00:00
parent 5a0f79827a
commit 13bbdba06d

View File

@ -153,7 +153,7 @@ def get_all(context, filters=None):
# same
result = []
for trait in db_traits:
if isinstance(trait, sa_row.LegacyRow):
if isinstance(trait, sa_row.Row):
result.append(Trait(context, **trait._mapping))
else:
result.append(Trait(context, **trait))