From d2f101cdfee0fd4e98c02d1ac8034f83c51ae82c Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 Jul 2021 19:16:36 +0100 Subject: Replace use of update.whereclause parameter Resolve the following RemovedIn20Warning: The update.whereclause parameter will be removed in SQLAlchemy 2.0. Please refer to the Update.where() method. Change-Id: I50064d16de6e1951b2282fcf9548a0ff2cd0fe55 Signed-off-by: Stephen Finucane --- oslo_db/sqlalchemy/update_match.py | 4 +++- oslo_db/tests/fixtures.py | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'oslo_db') diff --git a/oslo_db/sqlalchemy/update_match.py b/oslo_db/sqlalchemy/update_match.py index 0bfcfa8..559aa78 100644 --- a/oslo_db/sqlalchemy/update_match.py +++ b/oslo_db/sqlalchemy/update_match.py @@ -487,7 +487,9 @@ def _update_stmt_from_query(mapper, query, values): primary_table = inspect(query.column_descriptions[0]['entity']).local_table where_criteria = query.whereclause update_stmt = sql.update( - primary_table, where_criteria, + primary_table, + ).where( + where_criteria, ).values(upd_values) return update_stmt diff --git a/oslo_db/tests/fixtures.py b/oslo_db/tests/fixtures.py index d5552b0..8e70458 100644 --- a/oslo_db/tests/fixtures.py +++ b/oslo_db/tests/fixtures.py @@ -102,11 +102,6 @@ class WarningsFixture(fixtures.Fixture): message=r'Calling \.begin\(\) when a transaction is already .*', category=sqla_exc.SADeprecationWarning) - warnings.filterwarnings( - 'once', - message=r'The update.whereclause parameter will be removed .*', - category=sqla_exc.SADeprecationWarning) - warnings.filterwarnings( 'once', message=r'The Engine.scalar\(\) method is considered legacy .*', -- cgit v1.2.1