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 <stephenfin@redhat.com>
This commit is contained in:
parent
bb84f2b706
commit
493b20e875
@ -56,7 +56,7 @@ def cleanup_unassociated_projects():
|
|||||||
models.Project.id == model.project_id)
|
models.Project.id == model.project_id)
|
||||||
sub_query = sub_query.filter(model.id == None) # noqa
|
sub_query = sub_query.filter(model.id == None) # noqa
|
||||||
sub_query = sub_query.subquery()
|
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 = session.query(models.Project)
|
||||||
query = query.filter(models.Project.id.in_(sub_query))
|
query = query.filter(models.Project.id.in_(sub_query))
|
||||||
delete_count = query.delete(synchronize_session='fetch')
|
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.outerjoin(child_model)
|
||||||
sub_query = sub_query.filter(child_model.id == None) # noqa
|
sub_query = sub_query.filter(child_model.id == None) # noqa
|
||||||
sub_query = sub_query.subquery()
|
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 = session.query(parent_model)
|
||||||
query = query.filter(parent_model.id.in_(sub_query))
|
query = query.filter(parent_model.id.in_(sub_query))
|
||||||
query = query.filter(parent_model.deleted)
|
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.join(models.Secret)
|
||||||
acl_user_sub_query = acl_user_sub_query.filter(models.Secret.deleted)
|
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 = 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 = session.query(models.SecretACLUser)
|
||||||
acl_user_query = acl_user_query.filter(
|
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.join(models.Secret)
|
||||||
acl_sub_query = acl_sub_query.filter(models.Secret.deleted)
|
acl_sub_query = acl_sub_query.filter(models.Secret.deleted)
|
||||||
acl_sub_query = acl_sub_query.subquery()
|
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 = session.query(models.SecretACL)
|
||||||
acl_query = acl_query.filter(
|
acl_query = acl_query.filter(
|
||||||
@ -262,7 +262,7 @@ def _soft_delete_expired_secret_children(threshold_date):
|
|||||||
models.Secret.expiration <= threshold_date
|
models.Secret.expiration <= threshold_date
|
||||||
)
|
)
|
||||||
sub_query = sub_query.subquery()
|
sub_query = sub_query.subquery()
|
||||||
sub_query = sa_sql.select([sub_query])
|
sub_query = sa_sql.select(sub_query)
|
||||||
query = session.query(table)
|
query = session.query(table)
|
||||||
query = query.filter(table.id.in_(sub_query))
|
query = query.filter(table.id.in_(sub_query))
|
||||||
current_update_count = query.update(
|
current_update_count = query.update(
|
||||||
|
@ -190,13 +190,6 @@ class WarningsFixture(fixtures.Fixture):
|
|||||||
category=sqla_exc.SADeprecationWarning,
|
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
|
# 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
|
# silly stuff. It's possible that we'll need to filter things out here
|
||||||
# with future SQLAlchemy versions, but that's a good thing
|
# with future SQLAlchemy versions, but that's a good thing
|
||||||
|
Loading…
Reference in New Issue
Block a user