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>
This commit is contained in:
Stephen Finucane 2022-04-08 10:27:46 +01:00
parent 440fa6ab00
commit 287ef8d689
2 changed files with 2 additions and 8 deletions

View File

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

View File

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