From 09124fa689bbf40970b61beae7e1bb9c3938e6f8 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Tue, 16 Mar 2021 10:17:32 +0100 Subject: [PATCH] Resolve SADeprecationWarning for joinedload_all Method joinedload_all was deprecated in SQLAlchemy in version 0.9.0 and has been removed in version 1.4.0. Standard way of fixing this is by replacing joinedload_all with a custom method that chains joinedload calls for each word between ".". In Cinder's case it's not even necessary, since all our joinedload_all should have been joinedload in the first place. This patch replaces joinedload_all with joinedload to resolve the SADeprecationWarning issue and failure in newer releases. Closes-Bug: #1832164 Change-Id: I50dc67b12764e6baa0ef05983242029b1f3d765b --- cinder/db/sqlalchemy/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index d369b6607ed..348d2e76256 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -41,7 +41,7 @@ osprofiler_sqlalchemy = importutils.try_import('osprofiler.sqlalchemy') import sqlalchemy from sqlalchemy import MetaData from sqlalchemy import or_, and_, case -from sqlalchemy.orm import joinedload, joinedload_all, undefer_group, load_only +from sqlalchemy.orm import joinedload, undefer_group, load_only from sqlalchemy.orm import RelationshipProperty from sqlalchemy import sql from sqlalchemy.sql.expression import bindparam @@ -633,7 +633,7 @@ def _cluster_query(context, is_up=None, get_services=False, query = query.params(expired=utils.service_expired_time()) if get_services: - query = query.options(joinedload_all('services')) + query = query.options(joinedload('services')) if is_up is not None: date_limit = utils.service_expired_time() @@ -4614,7 +4614,7 @@ def _qos_specs_get_all_ref(context, qos_specs_id, session=None, result = model_query(context, models.QualityOfServiceSpecs, read_deleted=read_deleted, session=session). \ filter_by(id=qos_specs_id). \ - options(joinedload_all('specs')).all() + options(joinedload('specs')).all() if not result: raise exception.QoSSpecsNotFound(specs_id=qos_specs_id) @@ -4721,7 +4721,7 @@ def _qos_specs_get_query(context, session): rows = model_query(context, models.QualityOfServiceSpecs, session=session, read_deleted='no').\ - options(joinedload_all('specs')).filter_by(key='QoS_Specs_Name') + options(joinedload('specs')).filter_by(key='QoS_Specs_Name') return rows