db: Don't use legacy calling style of select()
Resolve the following RemovedIn20Warning warning: The legacy calling style of select() is deprecated and will be removed in SQLAlchemy 2.0. Please use the new calling style described at select(). Change-Id: I3a944dedc43502183726797279e1db3b1d5cb98d Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
77c924593f
commit
58f97d0525
@ -3361,7 +3361,7 @@ def volume_qos_allows_retype(new_vol_type):
|
||||
specifies anything other than the back-end in any of the 2 volume_types.
|
||||
"""
|
||||
# Query to get the qos of the volume type new_vol_type
|
||||
q = sql.select([models.VolumeType.qos_specs_id]).where(
|
||||
q = sql.select(models.VolumeType.qos_specs_id).where(
|
||||
and_(~models.VolumeType.deleted, models.VolumeType.id == new_vol_type)
|
||||
)
|
||||
# Construct the filter to check qos when volume is 'in-use'
|
||||
@ -7216,7 +7216,7 @@ def cg_creating_from_src(cg_id=None, cgsnapshot_id=None):
|
||||
# subquery to trick MySQL into using the same table in the update and the
|
||||
# where clause.
|
||||
subq = (
|
||||
sql.select([models.ConsistencyGroup])
|
||||
sql.select(models.ConsistencyGroup)
|
||||
.where(
|
||||
and_(
|
||||
~models.ConsistencyGroup.deleted,
|
||||
@ -7608,7 +7608,7 @@ def group_creating_from_src(group_id=None, group_snapshot_id=None):
|
||||
# subquery to trick MySQL into using the same table in the update and the
|
||||
# where clause.
|
||||
subq = (
|
||||
sql.select([models.Group])
|
||||
sql.select(models.Group)
|
||||
.where(and_(~models.Group.deleted, models.Group.status == 'creating'))
|
||||
.alias('group2')
|
||||
)
|
||||
@ -7624,7 +7624,7 @@ def group_creating_from_src(group_id=None, group_snapshot_id=None):
|
||||
)
|
||||
raise exception.ProgrammingError(reason=msg)
|
||||
|
||||
return sql.exists([subq]).where(match_id)
|
||||
return sql.exists(subq).where(match_id)
|
||||
|
||||
|
||||
@require_admin_context
|
||||
|
@ -150,7 +150,7 @@ class Cluster(BASE, CinderBase):
|
||||
# Last heartbeat reported by any of the services of this cluster. This is
|
||||
# not deferred since we always want to load this field.
|
||||
last_heartbeat = column_property(
|
||||
sa.select([func.max(Service.updated_at)])
|
||||
sa.select(func.max(Service.updated_at))
|
||||
.where(sa.and_(Service.cluster_name == name, ~Service.deleted))
|
||||
.correlate_except(Service)
|
||||
.scalar_subquery(),
|
||||
@ -159,7 +159,7 @@ class Cluster(BASE, CinderBase):
|
||||
|
||||
# Number of existing services for this cluster
|
||||
num_hosts = column_property(
|
||||
sa.select([func.count(Service.id)])
|
||||
sa.select(func.count(Service.id))
|
||||
.where(sa.and_(Service.cluster_name == name, ~Service.deleted))
|
||||
.correlate_except(Service)
|
||||
.scalar_subquery(),
|
||||
@ -169,7 +169,7 @@ class Cluster(BASE, CinderBase):
|
||||
|
||||
# Number of services that are down for this cluster
|
||||
num_down_hosts = column_property(
|
||||
sa.select([func.count(Service.id)])
|
||||
sa.select(func.count(Service.id))
|
||||
.where(
|
||||
sa.and_(
|
||||
Service.cluster_name == name,
|
||||
|
@ -218,13 +218,6 @@ class WarningsFixture(fixtures.Fixture):
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='cinder',
|
||||
message=r'The legacy calling style of select\(\) is deprecated ',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
self.addCleanup(self._reset_warning_filters)
|
||||
|
||||
def _reset_warning_filters(self):
|
||||
|
@ -458,9 +458,12 @@ these filters using the select subquery method like this:
|
||||
.. code:: python
|
||||
|
||||
def cg_creating_from_src(cg_id):
|
||||
subq = sql.select([models.ConsistencyGroup]).where(and_(
|
||||
~model.deleted,
|
||||
model.status == 'creating')).alias('cg2')
|
||||
subq = sql.select(models.ConsistencyGroup).where(
|
||||
and_(
|
||||
~model.deleted,
|
||||
model.status == 'creating'
|
||||
)
|
||||
).alias('cg2')
|
||||
|
||||
return sql.exists([subq]).where(subq.c.source_cgid == cgid)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user