From 13bbdba06da19f85c05a2a9e1fbdb9d1813c3b47 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 8 Feb 2022 12:57:56 +0000 Subject: [PATCH] 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 --- placement/objects/trait.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/placement/objects/trait.py b/placement/objects/trait.py index 077fa3437..e6d1bb388 100644 --- a/placement/objects/trait.py +++ b/placement/objects/trait.py @@ -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))