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:
parent
38c2effbf4
commit
0816efca7b
@ -112,11 +112,6 @@ class WarningsFixture(fixtures.Fixture):
|
|||||||
message=r'The Engine.scalar\(\) method is considered legacy .*',
|
message=r'The Engine.scalar\(\) method is considered legacy .*',
|
||||||
category=sqla_exc.SADeprecationWarning)
|
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
|
# ...plus things that aren't our fault
|
||||||
|
|
||||||
# FIXME(stephenfin): These are caused by sqlalchemy-migrate, not us,
|
# FIXME(stephenfin): These are caused by sqlalchemy-migrate, not us,
|
||||||
|
@ -20,7 +20,7 @@ import unittest
|
|||||||
|
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import sqlalchemy as sa
|
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 import exception as db_exc
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
@ -32,7 +32,7 @@ class EventletTestMixin(object):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(EventletTestMixin, self).setUp()
|
super(EventletTestMixin, self).setUp()
|
||||||
|
|
||||||
BASE = sa_decl.declarative_base()
|
BASE = orm.declarative_base()
|
||||||
|
|
||||||
class TmpTable(BASE, models.ModelBase):
|
class TmpTable(BASE, models.ModelBase):
|
||||||
__tablename__ = 'test_async_eventlet'
|
__tablename__ = 'test_async_eventlet'
|
||||||
|
@ -22,7 +22,7 @@ import sqlalchemy as sqla
|
|||||||
from sqlalchemy.engine import url as sqla_url
|
from sqlalchemy.engine import url as sqla_url
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.orm import declarative_base
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
from sqlalchemy import sql
|
from sqlalchemy import sql
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ from unittest import mock
|
|||||||
import fixtures
|
import fixtures
|
||||||
from migrate.versioning import api as versioning_api
|
from migrate.versioning import api as versioning_api
|
||||||
import sqlalchemy as sa
|
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 import exception as exc
|
||||||
from oslo_db.sqlalchemy import test_migrations as migrate
|
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'),
|
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):
|
class TestModel(BASE):
|
||||||
__tablename__ = 'testtbl'
|
__tablename__ = 'testtbl'
|
||||||
|
@ -20,7 +20,7 @@ from unittest import mock
|
|||||||
from sqlalchemy import Column
|
from sqlalchemy import Column
|
||||||
from sqlalchemy import Integer, String
|
from sqlalchemy import Integer, String
|
||||||
from sqlalchemy import event
|
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.sqlalchemy import models
|
||||||
from oslo_db.tests import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
@ -28,7 +28,7 @@ from sqlalchemy import sql
|
|||||||
from sqlalchemy import Column, MetaData, Table
|
from sqlalchemy import Column, MetaData, Table
|
||||||
from sqlalchemy.engine import url
|
from sqlalchemy.engine import url
|
||||||
from sqlalchemy import Integer, String
|
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 exception
|
||||||
from oslo_db import options as db_options
|
from oslo_db import options as db_options
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
from sqlalchemy import Column, Integer
|
from sqlalchemy import Column, Integer
|
||||||
from sqlalchemy.dialects import mysql
|
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 import exception as db_exc
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from sqlalchemy import orm
|
||||||
from sqlalchemy.ext import declarative
|
|
||||||
from sqlalchemy import schema
|
from sqlalchemy import schema
|
||||||
from sqlalchemy import sql
|
from sqlalchemy import sql
|
||||||
from sqlalchemy import types as sqltypes
|
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 import base as test_base
|
||||||
from oslo_db.tests.sqlalchemy import base as db_test_base
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
|
|
||||||
Base = declarative.declarative_base()
|
Base = orm.declarative_base()
|
||||||
|
|
||||||
|
|
||||||
class MyModel(Base):
|
class MyModel(Base):
|
||||||
|
@ -26,8 +26,8 @@ from sqlalchemy import ForeignKey, ForeignKeyConstraint
|
|||||||
from sqlalchemy.dialects.postgresql import psycopg2
|
from sqlalchemy.dialects.postgresql import psycopg2
|
||||||
from sqlalchemy.engine import url as sa_url
|
from sqlalchemy.engine import url as sa_url
|
||||||
from sqlalchemy.exc import OperationalError
|
from sqlalchemy.exc import OperationalError
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
|
from sqlalchemy.orm import declarative_base
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from sqlalchemy import PrimaryKeyConstraint
|
from sqlalchemy import PrimaryKeyConstraint
|
||||||
|
Loading…
Reference in New Issue
Block a user