summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2021-07-16 19:22:37 +0100
committerStephen Finucane <stephenfin@redhat.com>2021-08-10 16:53:47 +0100
commit8e7454c240aaed0d85bb3208f0ad0771c6b70c96 (patch)
tree5e0390de2413082d7068911fefc013a5bddf0c14
parent6a013c606b023b0ba7f3cb1bcc094d9adc1710f3 (diff)
downloadoslo-db-8e7454c240aaed0d85bb3208f0ad0771c6b70c96.tar.gz
Don't use plain string SQL statements
Resolve the following RemovedIn20Warning warning: Using plain strings to indicate SQL statements without using the text() construct is deprecated and will be removed in version 2.0. Ensure plain SQL statements are passed using the text() construct. Change-Id: I8acdb54d168afa1a7eac270ad6165faa287311ec Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
-rw-r--r--oslo_db/tests/fixtures.py5
-rw-r--r--oslo_db/tests/sqlalchemy/test_exc_filters.py10
2 files changed, 5 insertions, 10 deletions
diff --git a/oslo_db/tests/fixtures.py b/oslo_db/tests/fixtures.py
index 1f240ae..a1b6929 100644
--- a/oslo_db/tests/fixtures.py
+++ b/oslo_db/tests/fixtures.py
@@ -84,11 +84,6 @@ class WarningsFixture(fixtures.Fixture):
warnings.filterwarnings(
'once',
- message=r'Using plain strings to indicate SQL statements .*',
- category=sqla_exc.SADeprecationWarning)
-
- warnings.filterwarnings(
- 'once',
message=r'The current statement is being autocommitted .*',
category=sqla_exc.SADeprecationWarning)
diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py
index bb04986..9075f2a 100644
--- a/oslo_db/tests/sqlalchemy/test_exc_filters.py
+++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py
@@ -679,7 +679,7 @@ class TestExceptionCauseMySQLSavepoint(
with session.begin():
try:
with session.begin_nested():
- session.execute("rollback")
+ session.execute(sql.text("rollback"))
session.add(self.A(id=1))
# outermost is the failed SAVEPOINT rollback
# from the "with session.begin_nested()"
@@ -707,7 +707,7 @@ class TestExceptionCauseMySQLSavepoint(
session.begin()
try:
- session.execute("select 1")
+ session.execute(sql.text("select 1"))
# close underying DB connection
session.connection().connection.connection.close()
@@ -717,7 +717,7 @@ class TestExceptionCauseMySQLSavepoint(
# session.execute("kill connection %s" % conn_id)
# try using it, will raise an error
- session.execute("select 1")
+ session.execute(sql.text("select 1"))
except exception.DBConnectionError:
# issue being tested is that this session.rollback()
# does not itself try to re-connect and raise another
@@ -732,7 +732,7 @@ class TestExceptionCauseMySQLSavepoint(
session.begin()
try:
session.begin_nested()
- session.execute("select 1")
+ session.execute(sql.text("select 1"))
# close underying DB connection
session.connection().connection.connection.close()
@@ -742,7 +742,7 @@ class TestExceptionCauseMySQLSavepoint(
# session.execute("kill connection %s" % conn_id)
# try using it, will raise an error
- session.execute("select 1")
+ session.execute(sql.text("select 1"))
except exception.DBConnectionError:
# issue being tested is that this session.rollback()
# does not itself try to re-connect and raise another