mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-05 07:17:06 -04:00
- remove some remaining sys.modules shenanigans
- The "sqlalchemy.exceptions" alias in sys.modules has been removed. Base SQLA exceptions are available via "from sqlalchemy import exc". The "exceptions" alias for "exc" remains in "sqlalchemy" for now, it's just not patched into sys.modules.
This commit is contained in:
@@ -19,6 +19,13 @@ CHANGES
|
||||
- Setup no longer installs a Nose plugin
|
||||
[ticket:1949]
|
||||
|
||||
- The "sqlalchemy.exceptions" alias in sys.modules
|
||||
has been removed. Base SQLA exceptions are
|
||||
available via "from sqlalchemy import exc".
|
||||
The "exceptions" alias for "exc" remains in
|
||||
"sqlalchemy" for now, it's just not patched into
|
||||
sys.modules.
|
||||
|
||||
- orm
|
||||
- More succinct form of query.join(target, onclause)
|
||||
[ticket:1923]
|
||||
|
||||
@@ -8,7 +8,6 @@ import inspect
|
||||
import sys
|
||||
|
||||
import sqlalchemy.exc as exceptions
|
||||
sys.modules['sqlalchemy.exceptions'] = exceptions
|
||||
|
||||
from sqlalchemy.sql import (
|
||||
alias,
|
||||
|
||||
@@ -14,7 +14,7 @@ the source distrbution.
|
||||
|
||||
"""
|
||||
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import exc as sa_exc
|
||||
from sqlalchemy import util
|
||||
from sqlalchemy.orm.session import Session
|
||||
from sqlalchemy.orm.query import Query
|
||||
|
||||
@@ -367,7 +367,7 @@ from sqlalchemy.orm import scoped_session, sessionmaker, mapper, \
|
||||
class_mapper, relationship, session,\
|
||||
object_session, attributes
|
||||
from sqlalchemy.orm.interfaces import MapperExtension, EXT_CONTINUE
|
||||
from sqlalchemy.exceptions import SQLAlchemyError, InvalidRequestError, ArgumentError
|
||||
from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, ArgumentError
|
||||
from sqlalchemy.sql import expression
|
||||
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ defines a large part of the ORM's interactivity.
|
||||
import operator
|
||||
from operator import itemgetter
|
||||
|
||||
from sqlalchemy import util, event
|
||||
from sqlalchemy import util, event, exc as sa_exc
|
||||
from sqlalchemy.orm import interfaces, collections, events
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
|
||||
|
||||
mapperutil = util.importlater("sqlalchemy.orm", "util")
|
||||
|
||||
|
||||
@@ -108,9 +108,8 @@ import operator
|
||||
import sys
|
||||
import weakref
|
||||
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy.sql import expression
|
||||
from sqlalchemy import schema, util
|
||||
from sqlalchemy import schema, util, exc as sa_exc
|
||||
|
||||
|
||||
__all__ = ['collection', 'collection_adapter',
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from sqlalchemy import sql, util
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import sql, util, exc as sa_exc
|
||||
from sqlalchemy.orm import attributes, exc, sync, unitofwork, \
|
||||
util as mapperutil
|
||||
from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE, MANYTOMANY
|
||||
|
||||
@@ -18,7 +18,7 @@ classes within should be considered mostly private.
|
||||
|
||||
from itertools import chain
|
||||
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import exc as sa_exc
|
||||
from sqlalchemy import log, util, event
|
||||
from sqlalchemy.sql import expression
|
||||
deque = util.importlater('collections').deque
|
||||
|
||||
@@ -11,8 +11,7 @@ mapped attributes.
|
||||
|
||||
"""
|
||||
|
||||
from sqlalchemy import sql, util, log
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import sql, util, log, exc as sa_exc
|
||||
from sqlalchemy.sql.util import ClauseAdapter, criterion_as_pairs, \
|
||||
join_condition
|
||||
from sqlalchemy.sql import operators, expression
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# This module is part of SQLAlchemy and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import exc as sa_exc
|
||||
from sqlalchemy.util import ScopedRegistry, ThreadLocalRegistry, warn
|
||||
from sqlalchemy.orm import class_mapper
|
||||
from sqlalchemy.orm import exc as orm_exc
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
import weakref
|
||||
from itertools import chain
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import util, sql, engine, log
|
||||
from sqlalchemy import util, sql, engine, log, exc as sa_exc
|
||||
from sqlalchemy.sql import util as sql_util, expression
|
||||
from sqlalchemy.orm import (
|
||||
SessionExtension, attributes, exc, query, unitofwork, util as mapperutil, state
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
# This module is part of SQLAlchemy and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import sql, util, event
|
||||
|
||||
from sqlalchemy import sql, util, event, exc as sa_exc
|
||||
from sqlalchemy.sql import expression, util as sql_util, operators
|
||||
from sqlalchemy.orm.interfaces import MapperExtension, EXT_CONTINUE,\
|
||||
PropComparator, MapperProperty
|
||||
|
||||
@@ -34,7 +34,7 @@ from sqlalchemy import event, events
|
||||
|
||||
sqlutil = util.importlater("sqlalchemy.sql", "util")
|
||||
url = util.importlater("sqlalchemy.engine", "url")
|
||||
|
||||
sqltypes = util.importlater("sqlalchemy", "types")
|
||||
|
||||
__all__ = ['SchemaItem', 'Table', 'Column', 'ForeignKey', 'Sequence', 'Index',
|
||||
'ForeignKeyConstraint', 'PrimaryKeyConstraint', 'CheckConstraint',
|
||||
@@ -318,7 +318,7 @@ class Table(SchemaItem, expression.TableClause):
|
||||
def _autoincrement_column(self):
|
||||
for col in self.primary_key:
|
||||
if col.autoincrement and \
|
||||
issubclass(col.type._type_affinity, types.Integer) and \
|
||||
issubclass(col.type._type_affinity, sqltypes.Integer) and \
|
||||
not col.foreign_keys and \
|
||||
isinstance(col.default, (type(None), Sequence)) and \
|
||||
(col.server_default is None or col.server_default.reflected):
|
||||
@@ -679,9 +679,9 @@ class Column(SchemaItem, expression.ColumnClause):
|
||||
if args:
|
||||
coltype = args[0]
|
||||
|
||||
if (isinstance(coltype, types.TypeEngine) or
|
||||
if (isinstance(coltype, sqltypes.TypeEngine) or
|
||||
(isinstance(coltype, type) and
|
||||
issubclass(coltype, types.TypeEngine))):
|
||||
issubclass(coltype, sqltypes.TypeEngine))):
|
||||
if type_ is not None:
|
||||
raise exc.ArgumentError(
|
||||
"May not pass type_ positionally and as a keyword.")
|
||||
@@ -709,7 +709,7 @@ class Column(SchemaItem, expression.ColumnClause):
|
||||
if '_proxies' in kwargs:
|
||||
self.proxies = kwargs.pop('_proxies')
|
||||
# otherwise, add DDL-related events
|
||||
elif isinstance(self.type, types.SchemaType):
|
||||
elif isinstance(self.type, sqltypes.SchemaType):
|
||||
self.type._set_parent_with_dispatch(self)
|
||||
|
||||
if self.default is not None:
|
||||
@@ -1185,7 +1185,7 @@ class ForeignKey(SchemaItem):
|
||||
_column = self._colspec
|
||||
|
||||
# propagate TypeEngine to parent if it didn't have one
|
||||
if isinstance(self.parent.type, types.NullType):
|
||||
if isinstance(self.parent.type, sqltypes.NullType):
|
||||
self.parent.type = _column.type
|
||||
return _column
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ import codecs
|
||||
|
||||
from sqlalchemy import exc, schema
|
||||
from sqlalchemy.sql import expression, operators
|
||||
import sys
|
||||
schema.types = expression.sqltypes = sys.modules['sqlalchemy.types']
|
||||
from sqlalchemy.util import pickle
|
||||
from sqlalchemy.util.compat import decimal
|
||||
from sqlalchemy.sql.visitors import Visitable
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import inspect
|
||||
import sys
|
||||
import types
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy.exceptions as sa_exc
|
||||
from sqlalchemy import exc as sa_exc
|
||||
from test.lib import config, testing
|
||||
from test.lib.testing import resolve_artifact_names, adict
|
||||
from test.lib.engines import drop_all_tables
|
||||
|
||||
Reference in New Issue
Block a user