From 493b20e8755bdd8a5d832ef548d539d9f56334b0 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 12 Jul 2023 17:14:07 +0100 Subject: [PATCH] db: Update 'select()' calls 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(). For more information, refer to http://sqlalche.me/e/b8d9. Change-Id: I59e694358dfb3e6e6d0412a5519a412404260937 Signed-off-by: Stephen Finucane --- barbican/model/clean.py | 10 +++++----- barbican/tests/fixture.py | 7 ------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/barbican/model/clean.py b/barbican/model/clean.py index 6e732117d..319350b5a 100644 --- a/barbican/model/clean.py +++ b/barbican/model/clean.py @@ -56,7 +56,7 @@ def cleanup_unassociated_projects(): models.Project.id == model.project_id) sub_query = sub_query.filter(model.id == None) # noqa sub_query = sub_query.subquery() - sub_query = sa_sql.select([sub_query]) + sub_query = sa_sql.select(sub_query) query = session.query(models.Project) query = query.filter(models.Project.id.in_(sub_query)) delete_count = query.delete(synchronize_session='fetch') @@ -91,7 +91,7 @@ def cleanup_parent_with_no_child(parent_model, child_model, sub_query = sub_query.outerjoin(child_model) sub_query = sub_query.filter(child_model.id == None) # noqa sub_query = sub_query.subquery() - sub_query = sa_sql.select([sub_query]) + sub_query = sa_sql.select(sub_query) query = session.query(parent_model) query = query.filter(parent_model.id.in_(sub_query)) query = query.filter(parent_model.deleted) @@ -213,7 +213,7 @@ def _hard_delete_acls_for_soft_deleted_secrets(): acl_user_sub_query = acl_user_sub_query.join(models.Secret) acl_user_sub_query = acl_user_sub_query.filter(models.Secret.deleted) acl_user_sub_query = acl_user_sub_query.subquery() - acl_user_sub_query = sa_sql.select([acl_user_sub_query]) + acl_user_sub_query = sa_sql.select(acl_user_sub_query) acl_user_query = session.query(models.SecretACLUser) acl_user_query = acl_user_query.filter( @@ -224,7 +224,7 @@ def _hard_delete_acls_for_soft_deleted_secrets(): acl_sub_query = acl_sub_query.join(models.Secret) acl_sub_query = acl_sub_query.filter(models.Secret.deleted) acl_sub_query = acl_sub_query.subquery() - acl_sub_query = sa_sql.select([acl_sub_query]) + acl_sub_query = sa_sql.select(acl_sub_query) acl_query = session.query(models.SecretACL) acl_query = acl_query.filter( @@ -262,7 +262,7 @@ def _soft_delete_expired_secret_children(threshold_date): models.Secret.expiration <= threshold_date ) sub_query = sub_query.subquery() - sub_query = sa_sql.select([sub_query]) + sub_query = sa_sql.select(sub_query) query = session.query(table) query = query.filter(table.id.in_(sub_query)) current_update_count = query.update( diff --git a/barbican/tests/fixture.py b/barbican/tests/fixture.py index 1b5845fb6..89864babf 100644 --- a/barbican/tests/fixture.py +++ b/barbican/tests/fixture.py @@ -190,13 +190,6 @@ class WarningsFixture(fixtures.Fixture): category=sqla_exc.SADeprecationWarning, ) - warnings.filterwarnings( - 'ignore', - module='barbican', - message=r'The legacy calling style of select\(\) .*', - category=sqla_exc.SADeprecationWarning, - ) - # Enable general SQLAlchemy warnings also to ensure we're not doing # silly stuff. It's possible that we'll need to filter things out here # with future SQLAlchemy versions, but that's a good thing