summaryrefslogtreecommitdiff
path: root/oslo_db
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2021-07-19 11:40:08 +0100
committerStephen Finucane <stephenfin@redhat.com>2021-08-10 17:38:16 +0100
commitecb15c4ac63772e3332ac0f475e852f414ca3bbb (patch)
treeb887029407a89b04eaa680cb837e2654f0c965d0 /oslo_db
parente1039e0849890c6bd10516004c6dab89db1c9111 (diff)
downloadoslo-db-ecb15c4ac63772e3332ac0f475e852f414ca3bbb.tar.gz
Don't call mapper() outside of declarative registry
Resolve the following RemovedIn20Warning: Calling the mapper() function directly outside of a declarative registry is deprecated. Please use the sqlalchemy.orm.registry.map_imperatively() function for a classical mapping. Change-Id: I92a7ccdd48eedd4c788384033743daf50a9dc113 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'oslo_db')
-rw-r--r--oslo_db/tests/fixtures.py5
-rw-r--r--oslo_db/tests/sqlalchemy/test_enginefacade.py6
-rw-r--r--oslo_db/tests/sqlalchemy/test_exc_filters.py7
3 files changed, 9 insertions, 9 deletions
diff --git a/oslo_db/tests/fixtures.py b/oslo_db/tests/fixtures.py
index ccecccd..0168116 100644
--- a/oslo_db/tests/fixtures.py
+++ b/oslo_db/tests/fixtures.py
@@ -54,11 +54,6 @@ class WarningsFixture(fixtures.Fixture):
warnings.filterwarnings(
'once',
- message=r'Calling the mapper\(\) function directly outside .*',
- 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_enginefacade.py b/oslo_db/tests/sqlalchemy/test_enginefacade.py
index b24892b..a188d01 100644
--- a/oslo_db/tests/sqlalchemy/test_enginefacade.py
+++ b/oslo_db/tests/sqlalchemy/test_enginefacade.py
@@ -24,7 +24,7 @@ from oslo_context import context as oslo_context
from sqlalchemy import Column
from sqlalchemy import Integer
from sqlalchemy import MetaData
-from sqlalchemy.orm import mapper
+from sqlalchemy.orm import registry
from sqlalchemy.orm import Session
from sqlalchemy import select
from sqlalchemy import String
@@ -1671,11 +1671,13 @@ class LiveFacadeTest(db_test_base._DbTestCase):
metadata.create_all(self.engine)
self.addCleanup(metadata.drop_all, self.engine)
+ reg = registry()
+
class User(object):
def __init__(self, name):
self.name = name
- mapper(User, user_table)
+ reg.map_imperatively(User, user_table)
self.User = User
def _assert_ctx_connection(self, context, connection):
diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py
index a05c9a9..27a37a4 100644
--- a/oslo_db/tests/sqlalchemy/test_exc_filters.py
+++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py
@@ -23,7 +23,7 @@ from sqlalchemy.engine import url as sqla_url
from sqlalchemy import event
import sqlalchemy.exc
from sqlalchemy.orm import declarative_base
-from sqlalchemy.orm import mapper
+from sqlalchemy.orm import registry
from sqlalchemy import sql
from oslo_db import exception
@@ -1046,10 +1046,13 @@ class IntegrationTest(db_test_base._DbTestCase):
self.test_table.create(self.engine)
self.addCleanup(self.test_table.drop, self.engine)
+ reg = registry()
+
class Foo(object):
def __init__(self, counter):
self.counter = counter
- mapper(Foo, self.test_table)
+
+ reg.map_imperatively(Foo, self.test_table)
self.Foo = Foo
def test_flush_wrapper_duplicate_entry(self):