db: Don't pass strings to Connection.execute()
Resolve the following RemovedIn20Warning warning: Passing a string to Connection.execute() is deprecated and will be removed in version 2.0. Use the text() construct, or the Connection.exec_driver_sql() method to invoke a driver-level SQL string. We do the latter. Change-Id: I0ee518022772beeb0298e12b5b36279fd384fb4a Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
4545fdf69f
commit
69d62e3e6d
|
@ -23,8 +23,8 @@ from oslo_db.sqlalchemy import enginefacade
|
|||
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
from sqlalchemy import or_, and_
|
||||
from sqlalchemy.ext.compiler import compiles
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext import compiler
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy import sql
|
||||
|
@ -736,7 +736,7 @@ class DeleteFromSelect(sa_sql.expression.UpdateBase):
|
|||
|
||||
# NOTE(pooja_jadhav): MySQL doesn't yet support subquery with
|
||||
# 'LIMIT & IN/ALL/ANY/SOME' We need work around this with nesting select.
|
||||
@compiles(DeleteFromSelect)
|
||||
@compiler.compiles(DeleteFromSelect)
|
||||
def visit_delete_from_select(element, compiler, **kw):
|
||||
return "DELETE FROM %s WHERE %s in (SELECT T1.%s FROM (%s) as T1)" % (
|
||||
compiler.process(element.table, asfrom=True),
|
||||
|
@ -774,7 +774,7 @@ def purge_deleted_rows(context, age_in_days, max_rows):
|
|||
if table.name == 'notifications':
|
||||
status_column = table.c.status
|
||||
query_delete = sql.select([column]).where(
|
||||
and_(updated_at_column < deleted_age, or_(
|
||||
sa.and_(updated_at_column < deleted_age, sa.or_(
|
||||
status_column == 'finished', status_column == 'failed',
|
||||
status_column == 'ignored'))).order_by(status_column)
|
||||
else:
|
||||
|
|
|
@ -188,13 +188,6 @@ class WarningsFixture(fixtures.Fixture):
|
|||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
message=r'Passing a string to Connection.execute\(\)',
|
||||
module='masakari',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
message=r'The legacy calling style of select\(\)',
|
||||
|
|
|
@ -111,7 +111,7 @@ class PurgeDeletedTest(test.TestCase):
|
|||
|
||||
dialect = self.engine.url.get_dialect()
|
||||
if dialect == sqlite.dialect:
|
||||
self.conn.execute("PRAGMA foreign_keys = ON")
|
||||
self.conn.exec_driver_sql("PRAGMA foreign_keys = ON")
|
||||
|
||||
def _count(self, table):
|
||||
return self.conn.execute(
|
||||
|
|
Loading…
Reference in New Issue