Update import of declarative_base()

Resolve the following MovedIn20Warning:

  The ``declarative_base()`` function is now available as
  sqlalchemy.orm.declarative_base()

Change-Id: I5fd707c62d0bfad6e54150c4a3b87aadadbeedb3
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2021-07-16 19:15:14 +01:00
parent 38c2effbf4
commit 0816efca7b
9 changed files with 11 additions and 17 deletions

View File

@ -112,11 +112,6 @@ class WarningsFixture(fixtures.Fixture):
message=r'The Engine.scalar\(\) method is considered legacy .*',
category=sqla_exc.SADeprecationWarning)
warnings.filterwarnings(
'once',
message=r'The ``declarative_base\(\)`` function is now .*',
category=sqla_exc.SADeprecationWarning)
# ...plus things that aren't our fault
# FIXME(stephenfin): These are caused by sqlalchemy-migrate, not us,

View File

@ -20,7 +20,7 @@ import unittest
from oslo_utils import importutils
import sqlalchemy as sa
from sqlalchemy.ext import declarative as sa_decl
from sqlalchemy import orm
from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import models
@ -32,7 +32,7 @@ class EventletTestMixin(object):
def setUp(self):
super(EventletTestMixin, self).setUp()
BASE = sa_decl.declarative_base()
BASE = orm.declarative_base()
class TmpTable(BASE, models.ModelBase):
__tablename__ = 'test_async_eventlet'

View File

@ -22,7 +22,7 @@ import sqlalchemy as sqla
from sqlalchemy.engine import url as sqla_url
from sqlalchemy import event
import sqlalchemy.exc
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import mapper
from sqlalchemy import sql

View File

@ -19,7 +19,7 @@ from unittest import mock
import fixtures
from migrate.versioning import api as versioning_api
import sqlalchemy as sa
import sqlalchemy.ext.declarative as sa_decl
from sqlalchemy import orm
from oslo_db import exception as exc
from oslo_db.sqlalchemy import test_migrations as migrate
@ -215,7 +215,7 @@ class ModelsMigrationSyncMixin(db_test_base._DbTestCase):
sa.UniqueConstraint('spam', 'eggs', name='uniq_cons'),
)
BASE = sa_decl.declarative_base(metadata=self.metadata)
BASE = orm.declarative_base(metadata=self.metadata)
class TestModel(BASE):
__tablename__ = 'testtbl'

View File

@ -20,7 +20,7 @@ from unittest import mock
from sqlalchemy import Column
from sqlalchemy import Integer, String
from sqlalchemy import event
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base
from oslo_db.sqlalchemy import models
from oslo_db.tests import base as test_base

View File

@ -28,7 +28,7 @@ from sqlalchemy import sql
from sqlalchemy import Column, MetaData, Table
from sqlalchemy.engine import url
from sqlalchemy import Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base
from oslo_db import exception
from oslo_db import options as db_options

View File

@ -14,7 +14,7 @@
from sqlalchemy import Column, Integer
from sqlalchemy.dialects import mysql
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base
from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import models

View File

@ -10,8 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy.ext import declarative
from sqlalchemy import orm
from sqlalchemy import schema
from sqlalchemy import sql
from sqlalchemy import types as sqltypes
@ -20,7 +19,7 @@ from oslo_db.sqlalchemy import update_match
from oslo_db.tests import base as test_base
from oslo_db.tests.sqlalchemy import base as db_test_base
Base = declarative.declarative_base()
Base = orm.declarative_base()
class MyModel(Base):

View File

@ -26,8 +26,8 @@ from sqlalchemy import ForeignKey, ForeignKeyConstraint
from sqlalchemy.dialects.postgresql import psycopg2
from sqlalchemy.engine import url as sa_url
from sqlalchemy.exc import OperationalError
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import mapper
from sqlalchemy.orm import Session
from sqlalchemy import PrimaryKeyConstraint