summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2022-04-08 10:27:46 +0100
committerStephen Finucane <sfinucan@redhat.com>2022-04-08 15:56:59 +0100
commit287ef8d68973a50b611b443c97ed9c0d25226eb7 (patch)
tree1115d6e8eb661b7f774882cb2f2e5ed78607bf2b
parent440fa6ab00994167b4e0b7643bf791e88f5c52d8 (diff)
downloadnova-287ef8d68973a50b611b443c97ed9c0d25226eb7.tar.gz
db: Remove inplicit coercion of SELECTs
Resolve the following RemovedIn20Warning warning: Implicit coercion of SELECT and textual SELECT constructs into FROM clauses is deprecated; please call .subquery() on any Core select or ORM Query object in order to produce a subquery object. This one was easy. Change-Id: Ifeab2aa8cef7ad151d5d5f92937e90ab34b96e8a Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r--nova/db/main/api.py4
-rw-r--r--nova/tests/fixtures/nova.py6
2 files changed, 2 insertions, 8 deletions
diff --git a/nova/db/main/api.py b/nova/db/main/api.py
index 9ed9da6ccf..5ef693cbac 100644
--- a/nova/db/main/api.py
+++ b/nova/db/main/api.py
@@ -579,7 +579,7 @@ def _compute_node_select(context, filters=None, limit=None, marker=None):
if filters is None:
filters = {}
- cn_tbl = sa.alias(models.ComputeNode.__table__, name='cn')
+ cn_tbl = models.ComputeNode.__table__.alias('cn')
select = sa.select(cn_tbl)
if context.read_deleted == "no":
@@ -926,7 +926,7 @@ def compute_node_statistics(context):
engine = get_engine(context=context)
services_tbl = models.Service.__table__
- inner_sel = sa.alias(_compute_node_select(context), name='inner_sel')
+ inner_sel = _compute_node_select(context).alias('inner_sel')
# TODO(sbauza): Remove the service_id filter in a later release
# once we are sure that all compute nodes report the host field
diff --git a/nova/tests/fixtures/nova.py b/nova/tests/fixtures/nova.py
index 3baeb1f3e2..a36749e043 100644
--- a/nova/tests/fixtures/nova.py
+++ b/nova/tests/fixtures/nova.py
@@ -885,12 +885,6 @@ class WarningsFixture(fixtures.Fixture):
message=r'The Column.copy\(\) method is deprecated .*',
category=sqla_exc.SADeprecationWarning)
- warnings.filterwarnings(
- 'ignore',
- module='nova',
- message='Implicit coercion of SELECT and textual SELECT .*',
- category=sqla_exc.SADeprecationWarning)
-
self.addCleanup(self._reset_warning_filters)
def _reset_warning_filters(self):