summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-11-26 16:28:41 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-11-26 16:28:41 -0500
commitf1e4718f79564e53e2cee8ba51bbdf8af84bc903 (patch)
treeb58ead590c18d519800f05660293b26f3af5f87f
parent45cdb17ef0b08f31a42423554ec94ed913fb31fe (diff)
parent6dfbe839aaf026e72ecb079fc7608ad6c09babf8 (diff)
downloadsqlalchemy-f1e4718f79564e53e2cee8ba51bbdf8af84bc903.tar.gz
- merge mapper simpler compile branch, [ticket:1966]
-rw-r--r--examples/versioning/test_versioning.py2
-rw-r--r--lib/sqlalchemy/orm/__init__.py16
-rw-r--r--lib/sqlalchemy/orm/mapper.py182
-rw-r--r--lib/sqlalchemy/orm/properties.py6
-rw-r--r--lib/sqlalchemy/orm/state.py8
-rw-r--r--lib/sqlalchemy/orm/util.py15
-rw-r--r--lib/sqlalchemy/util.py4
-rw-r--r--test/ext/test_declarative.py38
-rw-r--r--test/ext/test_serializer.py4
-rw-r--r--test/orm/inheritance/test_basic.py2
-rw-r--r--test/orm/inheritance/test_poly_linked_list.py4
-rw-r--r--test/orm/test_compile.py35
-rw-r--r--test/orm/test_manytomany.py2
-rw-r--r--test/orm/test_mapper.py79
-rw-r--r--test/orm/test_pickled.py2
-rw-r--r--test/orm/test_query.py2
-rw-r--r--test/orm/test_relationships.py94
-rw-r--r--test/orm/test_unitofwork.py4
18 files changed, 267 insertions, 232 deletions
diff --git a/examples/versioning/test_versioning.py b/examples/versioning/test_versioning.py
index 031d7ca26..ed88be6e7 100644
--- a/examples/versioning/test_versioning.py
+++ b/examples/versioning/test_versioning.py
@@ -1,7 +1,7 @@
from sqlalchemy.ext.declarative import declarative_base
from history_meta import VersionedMeta, VersionedListener
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey
-from sqlalchemy.orm import clear_mappers, compile_mappers, sessionmaker, deferred
+from sqlalchemy.orm import clear_mappers, sessionmaker, deferred
from sqlalchemy.test.testing import TestBase, eq_
from sqlalchemy.test.entities import ComparableEntity
diff --git a/lib/sqlalchemy/orm/__init__.py b/lib/sqlalchemy/orm/__init__.py
index c08b09c50..659484691 100644
--- a/lib/sqlalchemy/orm/__init__.py
+++ b/lib/sqlalchemy/orm/__init__.py
@@ -18,6 +18,7 @@ from sqlalchemy.orm.mapper import (
Mapper,
_mapper_registry,
class_mapper,
+ configure_mappers
)
from sqlalchemy.orm.interfaces import (
EXT_CONTINUE,
@@ -73,6 +74,7 @@ __all__ = (
'column_property',
'comparable_property',
'compile_mappers',
+ 'configure_mappers',
'composite',
'contains_alias',
'contains_eager',
@@ -976,15 +978,13 @@ def comparable_property(comparator_factory, descriptor=None):
"""
return ComparableProperty(comparator_factory, descriptor)
-
+
+@sa_util.deprecated("0.7", message=":func:`.compile_mappers` "
+ "is renamed to :func:`.configure_mappers`")
def compile_mappers():
- """Compile all mappers that have been defined.
-
- This is equivalent to calling ``compile()`` on any individual mapper.
-
- """
- for m in list(_mapper_registry):
- m.compile()
+ """Initialize the inter-mapper relationships of all mappers that have been defined."""
+
+ configure_mappers()
def clear_mappers():
"""Remove all mappers from all classes.
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 32eb8f643..0721f7376 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -46,7 +46,7 @@ _new_mappers = False
_already_compiling = False
_none_set = frozenset([None])
-_memoized_compiled_property = util.group_expirable_memoized_property()
+_memoized_configured_property = util.group_expirable_memoized_property()
# a constant returned by _get_attr_by_column to indicate
# this mapper is not handling an attribute for a particular
@@ -196,10 +196,10 @@ class Mapper(object):
else:
self.exclude_properties = None
- self.compiled = False
+ self.configured = False
# prevent this mapper from being constructed
- # while a compile() is occuring (and defer a compile()
+ # while a configure_mappers() is occuring (and defer a configure_mappers()
# until construction succeeds)
_COMPILE_MUTEX.acquire()
try:
@@ -413,13 +413,30 @@ class Mapper(object):
self._validators[name] = method
manager.info[_INSTRUMENTOR] = self
-
+
+ @util.deprecated("0.7", message=":meth:`.Mapper.compile` "
+ "is replaced by :func:`.configure_mappers`")
+ def compile(self):
+ """Initialize the inter-mapper relationships of all mappers that
+ have been constructed thus far.
+
+ """
+ configure_mappers()
+ return self
+
+
+ @property
+ @util.deprecated("0.7", message=":attr:`.Mapper.compiled` "
+ "is replaced by :attr:`.Mapper.configured`")
+ def compiled(self):
+ return self.configured
+
def dispose(self):
# Disable any attribute-based compilation.
- self.compiled = True
+ self.configured = True
- if hasattr(self, '_compile_failed'):
- del self._compile_failed
+ if hasattr(self, '_configure_failed'):
+ del self._configure_failed
if not self.non_primary and \
self.class_manager.is_mapped and \
@@ -775,60 +792,6 @@ class Mapper(object):
prop.post_instrument_class(self)
- def compile(self):
- """Compile this mapper and all other non-compiled mappers.
-
- This method checks the local compiled status as well as for
- any new mappers that have been defined, and is safe to call
- repeatedly.
-
- """
- global _new_mappers
- if self.compiled and not _new_mappers:
- return self
-
- _COMPILE_MUTEX.acquire()
- try:
- try:
- global _already_compiling
- if _already_compiling:
- return
- _already_compiling = True
- try:
-
- # double-check inside mutex
- if self.compiled and not _new_mappers:
- return self
-
- # initialize properties on all mappers
- # note that _mapper_registry is unordered, which
- # may randomly conceal/reveal issues related to
- # the order of mapper compilation
- for mapper in list(_mapper_registry):
- if getattr(mapper, '_compile_failed', False):
- e = sa_exc.InvalidRequestError(
- "One or more mappers failed to initialize - "
- "can't proceed with initialization of other "
- "mappers. Original exception was: %s"
- % mapper._compile_failed)
- e._compile_failed = mapper._compile_failed
- raise e
- if not mapper.compiled:
- mapper._post_configure_properties()
-
- _new_mappers = False
- return self
- finally:
- _already_compiling = False
- except:
- exc = sys.exc_info()[1]
- if not hasattr(exc, '_compile_failed'):
- self._compile_failed = exc
- raise
- finally:
- self._expire_memoizations()
- _COMPILE_MUTEX.release()
-
def _post_configure_properties(self):
"""Call the ``init()`` method on all ``MapperProperties``
attached to this mapper.
@@ -850,7 +813,7 @@ class Mapper(object):
prop.post_instrument_class(self)
self._log("_post_configure_properties() complete")
- self.compiled = True
+ self.configured = True
def add_properties(self, dict_of_properties):
"""Add the given dictionary of properties to this mapper,
@@ -863,19 +826,19 @@ class Mapper(object):
def add_property(self, key, prop):
"""Add an individual MapperProperty to this mapper.
- If the mapper has not been compiled yet, just adds the
+ If the mapper has not been configured yet, just adds the
property to the initial properties dictionary sent to the
- constructor. If this Mapper has already been compiled, then
- the given MapperProperty is compiled immediately.
+ constructor. If this Mapper has already been configured, then
+ the given MapperProperty is configured immediately.
"""
self._init_properties[key] = prop
- self._configure_property(key, prop, init=self.compiled)
+ self._configure_property(key, prop, init=self.configured)
self._expire_memoizations()
def _expire_memoizations(self):
for mapper in self.iterate_to_root():
- _memoized_compiled_property.expire_instance(mapper)
+ _memoized_configured_property.expire_instance(mapper)
def _log(self, msg, *args):
self.logger.info(
@@ -930,8 +893,9 @@ class Mapper(object):
"""
- if _compile_mappers and not self.compiled:
- self.compile()
+ if _compile_mappers and _new_mappers:
+ configure_mappers()
+
try:
return getattr(self.class_, key).property
except AttributeError:
@@ -953,8 +917,8 @@ class Mapper(object):
@property
def iterate_properties(self):
"""return an iterator of all MapperProperty objects."""
- if not self.compiled:
- self.compile()
+ if _new_mappers:
+ configure_mappers()
return self._props.itervalues()
def _mappers_from_spec(self, spec, selectable):
@@ -1005,7 +969,7 @@ class Mapper(object):
return from_obj
- @_memoized_compiled_property
+ @_memoized_configured_property
def _single_table_criterion(self):
if self.single and \
self.inherits and \
@@ -1017,13 +981,13 @@ class Mapper(object):
else:
return None
- @_memoized_compiled_property
+ @_memoized_configured_property
def _with_polymorphic_mappers(self):
if not self.with_polymorphic:
return [self]
return self._mappers_from_spec(*self.with_polymorphic)
- @_memoized_compiled_property
+ @_memoized_configured_property
def _with_polymorphic_selectable(self):
if not self.with_polymorphic:
return self.mapped_table
@@ -1048,7 +1012,7 @@ class Mapper(object):
else:
return mappers, self._selectable_from_mappers(mappers)
- @_memoized_compiled_property
+ @_memoized_configured_property
def _polymorphic_properties(self):
return tuple(self._iterate_polymorphic_properties(
self._with_polymorphic_mappers))
@@ -1084,7 +1048,7 @@ class Mapper(object):
"provided by the get_property() and iterate_properties "
"accessors.")
- @_memoized_compiled_property
+ @_memoized_configured_property
def _get_clause(self):
"""create a "get clause" based on the primary key. this is used
by query.get() and many-to-one lazyloads to load this item
@@ -1096,7 +1060,7 @@ class Mapper(object):
return sql.and_(*[k==v for (k, v) in params]), \
util.column_dict(params)
- @_memoized_compiled_property
+ @_memoized_configured_property
def _equivalent_columns(self):
"""Create a map of all *equivalent* columns, based on
the determination of column pairs that are equated to
@@ -1209,7 +1173,7 @@ class Mapper(object):
yield m
m = m.inherits
- @_memoized_compiled_property
+ @_memoized_configured_property
def self_and_descendants(self):
"""The collection including this mapper and all descendant mappers.
@@ -1433,11 +1397,11 @@ class Mapper(object):
visitables.append((deque(instance_mapper._props.values()),
prp, corresponding_state))
- @_memoized_compiled_property
+ @_memoized_configured_property
def _compiled_cache(self):
return util.LRUCache(self._compiled_cache_size)
- @_memoized_compiled_property
+ @_memoized_configured_property
def _sorted_tables(self):
table_to_mapper = {}
for mapper in self.base_mapper.self_and_descendants:
@@ -2354,6 +2318,60 @@ class Mapper(object):
log.class_logger(Mapper)
+def configure_mappers():
+ """Initialize the inter-mapper relationships of all mappers that
+ have been constructed thus far.
+
+ This function can be called any number of times, but in
+ most cases is handled internally.
+
+ """
+
+ global _new_mappers
+ if not _new_mappers:
+ return
+
+ _COMPILE_MUTEX.acquire()
+ try:
+ global _already_compiling
+ if _already_compiling:
+ return
+ _already_compiling = True
+ try:
+
+ # double-check inside mutex
+ if not _new_mappers:
+ return
+
+ # initialize properties on all mappers
+ # note that _mapper_registry is unordered, which
+ # may randomly conceal/reveal issues related to
+ # the order of mapper compilation
+ for mapper in list(_mapper_registry):
+ if getattr(mapper, '_configure_failed', False):
+ e = sa_exc.InvalidRequestError(
+ "One or more mappers failed to initialize - "
+ "can't proceed with initialization of other "
+ "mappers. Original exception was: %s"
+ % mapper._configure_failed)
+ e._configure_failed = mapper._configure_failed
+ raise e
+ if not mapper.configured:
+ try:
+ mapper._post_configure_properties()
+ mapper._expire_memoizations()
+ except:
+ exc = sys.exc_info()[1]
+ if not hasattr(exc, '_configure_failed'):
+ mapper._configure_failed = exc
+ raise
+
+ _new_mappers = False
+ finally:
+ _already_compiling = False
+ finally:
+ _COMPILE_MUTEX.release()
+
def reconstructor(fn):
"""Decorate a method as the 'reconstructor' hook.
@@ -2405,8 +2423,8 @@ def _event_on_init(state, args, kwargs):
instrumenting_mapper = state.manager.info.get(_INSTRUMENTOR)
if instrumenting_mapper:
- # compile() always compiles all mappers
- instrumenting_mapper.compile()
+ if _new_mappers:
+ configure_mappers()
if instrumenting_mapper._set_polymorphic_identity:
instrumenting_mapper._set_polymorphic_identity(state)
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index 8c98adf8c..b68290dbd 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -18,11 +18,12 @@ from sqlalchemy.sql.util import ClauseAdapter, criterion_as_pairs, \
join_condition
from sqlalchemy.sql import operators, expression
from sqlalchemy.orm import attributes, dependency, mapper, \
- object_mapper, strategies
+ object_mapper, strategies, configure_mappers
from sqlalchemy.orm.util import CascadeOptions, _class_to_mapper, \
_orm_annotate, _orm_deannotate
from sqlalchemy.orm.interfaces import MANYTOMANY, MANYTOONE, \
MapperProperty, ONETOMANY, PropComparator, StrategizedProperty
+mapperlib = util.importlater("sqlalchemy.orm", "mapperlib")
NoneType = type(None)
__all__ = ('ColumnProperty', 'CompositeProperty', 'SynonymProperty',
@@ -730,7 +731,8 @@ class RelationshipProperty(StrategizedProperty):
@util.memoized_property
def property(self):
- self.prop.parent.compile()
+ if mapperlib.module._new_mappers:
+ configure_mappers()
return self.prop
def compare(self, op, value,
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py
index 3e977a4c9..059788bac 100644
--- a/lib/sqlalchemy/orm/state.py
+++ b/lib/sqlalchemy/orm/state.py
@@ -8,11 +8,13 @@ defines a large part of the ORM's interactivity.
from sqlalchemy.util import EMPTY_SET
import weakref
from sqlalchemy import util
-
+
from sqlalchemy.orm import exc as orm_exc, attributes, interfaces
from sqlalchemy.orm.attributes import PASSIVE_OFF, PASSIVE_NO_RESULT, \
PASSIVE_NO_FETCH, NEVER_SET, ATTR_WAS_SET, NO_VALUE
+mapperlib = util.importlater("sqlalchemy.orm", "mapperlib")
+
import sys
class InstanceState(object):
@@ -166,8 +168,8 @@ class InstanceState(object):
"Cannot deserialize object of type %r - no mapper() has"
" been configured for this class within the current Python process!" %
self.class_)
- elif manager.is_mapped and not manager.mapper.compiled:
- manager.mapper.compile()
+ elif manager.is_mapped and not manager.mapper.configured:
+ mapperlib.configure_mappers()
self.committed_state = state.get('committed_state', {})
self.pending = state.get('pending', {})
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 0e0d6f568..4661b4b00 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -471,8 +471,8 @@ def _entity_info(entity, compile=True):
else:
return None, entity, False
- if compile:
- mapper = mapper.compile()
+ if compile and mapperlib.module._new_mappers:
+ mapperlib.configure_mappers()
return mapper, mapper._with_polymorphic_selectable, False
def _entity_descriptor(entity, key):
@@ -545,8 +545,8 @@ def class_mapper(class_, compile=True):
except exc.NO_STATE:
raise exc.UnmappedClassError(class_)
- if compile:
- mapper = mapper.compile()
+ if compile and mapperlib.module._new_mappers:
+ mapperlib.configure_mappers()
return mapper
def _class_to_mapper(class_or_mapper, compile=True):
@@ -564,10 +564,9 @@ def _class_to_mapper(class_or_mapper, compile=True):
else:
raise exc.UnmappedClassError(class_or_mapper)
- if compile:
- return mapper.compile()
- else:
- return mapper
+ if compile and mapperlib.module._new_mappers:
+ mapperlib.configure_mappers()
+ return mapper
def has_identity(object):
state = attributes.instance_state(object)
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index 7e4ec1396..5416fcfbb 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -1592,7 +1592,7 @@ class importlater(object):
self._il_addtl = addtl
@memoized_property
- def _il_module(self):
+ def module(self):
m = __import__(self._il_path)
for token in self._il_path.split(".")[1:]:
m = getattr(m, token)
@@ -1609,7 +1609,7 @@ class importlater(object):
def __getattr__(self, key):
try:
- attr = getattr(self._il_module, key)
+ attr = getattr(self.module, key)
except AttributeError:
raise AttributeError(
"Module %s has no attribute '%s'" %
diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py
index 88fd5b976..32173cdc1 100644
--- a/test/ext/test_declarative.py
+++ b/test/ext/test_declarative.py
@@ -9,7 +9,7 @@ from sqlalchemy import MetaData, Integer, String, ForeignKey, \
ForeignKeyConstraint, asc, Index
from sqlalchemy.test.schema import Table, Column
from sqlalchemy.orm import relationship, create_session, class_mapper, \
- joinedload, compile_mappers, backref, clear_mappers, \
+ joinedload, configure_mappers, backref, clear_mappers, \
polymorphic_union, deferred, column_property
from sqlalchemy.test.testing import eq_
from sqlalchemy.util import classproperty
@@ -209,7 +209,7 @@ class DeclarativeTest(DeclarativeTestBase):
assert_raises_message(exc.InvalidRequestError,
"'addresses' is not an instance of "
- "ColumnProperty", compile_mappers)
+ "ColumnProperty", configure_mappers)
def test_string_dependency_resolution_two(self):
@@ -227,7 +227,7 @@ class DeclarativeTest(DeclarativeTestBase):
assert_raises_message(exc.InvalidRequestError,
"does not have a mapped column named "
- "'__table__'", compile_mappers)
+ "'__table__'", configure_mappers)
def test_string_dependency_resolution_no_magic(self):
"""test that full tinkery expressions work as written"""
@@ -246,7 +246,7 @@ class DeclarativeTest(DeclarativeTestBase):
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('users.id'))
- compile_mappers()
+ configure_mappers()
eq_(str(User.addresses.prop.primaryjoin),
'users.id = addresses.user_id')
@@ -268,7 +268,7 @@ class DeclarativeTest(DeclarativeTestBase):
email = Column(String(50))
user_id = Column(Integer, ForeignKey('users.id'))
- compile_mappers()
+ configure_mappers()
eq_(str(User.addresses.property.primaryjoin),
str(Address.user.property.primaryjoin))
@@ -295,7 +295,7 @@ class DeclarativeTest(DeclarativeTestBase):
Column('user_id', Integer,
ForeignKey('users.id')), Column('prop_id',
Integer, ForeignKey('props.id')))
- compile_mappers()
+ configure_mappers()
assert class_mapper(User).get_property('props').secondary \
is user_to_prop
@@ -326,7 +326,7 @@ class DeclarativeTest(DeclarativeTestBase):
Column('user_id', Integer, ForeignKey('fooschema.users.id')),
Column('prop_id',Integer, ForeignKey('fooschema.props.id')),
schema='fooschema')
- compile_mappers()
+ configure_mappers()
assert class_mapper(User).get_property('props').secondary \
is user_to_prop
@@ -388,7 +388,7 @@ class DeclarativeTest(DeclarativeTestBase):
# this used to raise an error when accessing User.id but that's
# no longer the case since we got rid of _CompileOnAttr.
- assert_raises(sa.exc.ArgumentError, compile_mappers)
+ assert_raises(sa.exc.ArgumentError, configure_mappers)
def test_nice_dependency_error_works_with_hasattr(self):
@@ -409,7 +409,7 @@ class DeclarativeTest(DeclarativeTestBase):
"^One or more mappers failed to initialize - "
"can't proceed with initialization of other "
"mappers. Original exception was: When initializing.*",
- compile_mappers)
+ configure_mappers)
def test_custom_base(self):
class MyBase(object):
@@ -438,7 +438,7 @@ class DeclarativeTest(DeclarativeTestBase):
master = relationship(Master)
Base.metadata.create_all()
- compile_mappers()
+ configure_mappers()
assert class_mapper(Detail).get_property('master'
).strategy.use_get
m1 = Master()
@@ -465,7 +465,7 @@ class DeclarativeTest(DeclarativeTestBase):
i = Index('my_index', User.name)
# compile fails due to the nonexistent Addresses relationship
- assert_raises(sa.exc.InvalidRequestError, compile_mappers)
+ assert_raises(sa.exc.InvalidRequestError, configure_mappers)
# index configured
assert i in User.__table__.indexes
@@ -1000,7 +1000,7 @@ class DeclarativeTest(DeclarativeTestBase):
# the User.id inside the ForeignKey but this is no longer the
# case
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
eq_(str(Address.user_id.property.columns[0].foreign_keys[0]),
"ForeignKey('users.id')")
Base.metadata.create_all()
@@ -1205,7 +1205,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
# compile succeeds because inherit_condition is honored
- compile_mappers()
+ configure_mappers()
def test_joined(self):
@@ -1469,7 +1469,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase):
related_child1 = Column('c1', Integer)
__mapper_args__ = dict(polymorphic_identity='child2')
- sa.orm.compile_mappers() # no exceptions here
+ sa.orm.configure_mappers() # no exceptions here
def test_foreign_keys_with_col(self):
"""Test that foreign keys that reference a literal 'id' subclass
@@ -2012,7 +2012,7 @@ def _produce_test(inline, stringbased):
== user_id, backref='addresses')
if not inline:
- compile_mappers()
+ configure_mappers()
if stringbased:
Address.user = relationship('User',
primaryjoin='User.id==Address.user_id',
@@ -2568,7 +2568,7 @@ class DeclarativeMixinTest(DeclarativeTestBase):
class Engineer(Person):
pass
- compile_mappers()
+ configure_mappers()
assert class_mapper(Person).polymorphic_on \
is Person.__table__.c.type
eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer')
@@ -2595,7 +2595,7 @@ class DeclarativeMixinTest(DeclarativeTestBase):
class Engineer(Person, ComputedMapperArgs):
pass
- compile_mappers()
+ configure_mappers()
assert class_mapper(Person).polymorphic_on \
is Person.__table__.c.type
eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer')
@@ -3123,7 +3123,7 @@ class DeclarativeMixinPropertyTest(DeclarativeTestBase):
__tablename__ = 'test'
id = Column(Integer, primary_key=True)
- compile_mappers()
+ configure_mappers()
eq_(MyModel.type_.__doc__, """this is a document.""")
eq_(MyModel.t2.__doc__, """this is another document.""")
@@ -3141,7 +3141,7 @@ class DeclarativeMixinPropertyTest(DeclarativeTestBase):
__tablename__ = 'test'
id = Column(Integer, primary_key=True)
- compile_mappers()
+ configure_mappers()
col = MyModel.__mapper__.polymorphic_on
eq_(col.name, 'type_')
assert col.table is not None
diff --git a/test/ext/test_serializer.py b/test/ext/test_serializer.py
index 45f55e1c9..ca9de27e7 100644
--- a/test/ext/test_serializer.py
+++ b/test/ext/test_serializer.py
@@ -8,7 +8,7 @@ from sqlalchemy import MetaData, Integer, String, ForeignKey, select, \
from sqlalchemy.test.schema import Table
from sqlalchemy.test.schema import Column
from sqlalchemy.orm import relationship, sessionmaker, scoped_session, \
- class_mapper, mapper, joinedload, compile_mappers, aliased
+ class_mapper, mapper, joinedload, configure_mappers, aliased
from sqlalchemy.test.testing import eq_
from test.orm._base import ComparableEntity, MappedTest
@@ -44,7 +44,7 @@ class SerializeTest(MappedTest):
: relationship(Address, backref='user',
order_by=addresses.c.id)})
mapper(Address, addresses)
- compile_mappers()
+ configure_mappers()
@classmethod
def insert_data(cls):
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index 896c7618f..e7461842f 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -109,7 +109,7 @@ class PolymorphicOnNotLocalTest(_base.MappedTest):
polymorphic_on=t1t2_join.c.x,
with_polymorphic=('*', t1t2_join),
polymorphic_identity=0)
- compile_mappers()
+ configure_mappers()
clear_mappers()
diff --git a/test/orm/inheritance/test_poly_linked_list.py b/test/orm/inheritance/test_poly_linked_list.py
index e16c95555..01dad72e4 100644
--- a/test/orm/inheritance/test_poly_linked_list.py
+++ b/test/orm/inheritance/test_poly_linked_list.py
@@ -79,7 +79,7 @@ class PolymorphicCircularTest(_base.MappedTest):
'data':relationship(mapper(Data, data))
},
order_by=table1.c.id)
- table1_mapper.compile()
+ configure_mappers()
assert False
except:
assert True
@@ -112,7 +112,7 @@ class PolymorphicCircularTest(_base.MappedTest):
table3_mapper = mapper(Table3, table3, inherits=table1_mapper, polymorphic_identity='table3')
- table1_mapper.compile()
+ configure_mappers()
assert table1_mapper.primary_key == [table1.c.id], table1_mapper.primary_key
@testing.fails_on('maxdb', 'FIXME: unknown')
diff --git a/test/orm/test_compile.py b/test/orm/test_compile.py
index 101e4143a..575c3ccfb 100644
--- a/test/orm/test_compile.py
+++ b/test/orm/test_compile.py
@@ -2,6 +2,7 @@ from sqlalchemy import *
from sqlalchemy import exc as sa_exc
from sqlalchemy.orm import *
from sqlalchemy.test import *
+from sqlalchemy.test.testing import assert_raises_message
from test.orm import _base
@@ -11,7 +12,7 @@ class CompileTest(_base.ORMTest):
def teardown(self):
clear_mappers()
- def testone(self):
+ def test_with_polymorphic(self):
metadata = MetaData(testing.db)
order = Table('orders', metadata,
@@ -69,9 +70,9 @@ class CompileTest(_base.ORMTest):
# this requires that the compilation of order_mapper's "surrogate
# mapper" occur after the initial setup of MapperProperty objects on
# the mapper.
- class_mapper(Product).compile()
+ configure_mappers()
- def testtwo(self):
+ def test_conflicting_backref_one(self):
"""test that conflicting backrefs raises an exception"""
metadata = MetaData(testing.db)
@@ -115,13 +116,13 @@ class CompileTest(_base.ORMTest):
mapper(OrderProduct, orderproduct)
- try:
- class_mapper(Product).compile()
- assert False
- except sa_exc.ArgumentError, e:
- assert str(e).index("Error creating backref ") > -1
+ assert_raises_message(
+ sa_exc.ArgumentError,
+ "Error creating backref",
+ configure_mappers
+ )
- def testthree(self):
+ def test_misc_one(self):
metadata = MetaData(testing.db)
node_table = Table("node", metadata,
Column('node_id', Integer, primary_key=True),
@@ -158,11 +159,12 @@ class CompileTest(_base.ORMTest):
finally:
metadata.drop_all()
- def testfour(self):
+ def test_conflicting_backref_two(self):
meta = MetaData()
a = Table('a', meta, Column('id', Integer, primary_key=True))
- b = Table('b', meta, Column('id', Integer, primary_key=True), Column('a_id', Integer, ForeignKey('a.id')))
+ b = Table('b', meta, Column('id', Integer, primary_key=True),
+ Column('a_id', Integer, ForeignKey('a.id')))
class A(object):pass
class B(object):pass
@@ -174,10 +176,9 @@ class CompileTest(_base.ORMTest):
'a':relationship(A, backref='b')
})
- try:
- compile_mappers()
- assert False
- except sa_exc.ArgumentError, e:
- assert str(e).index("Error creating backref") > -1
-
+ assert_raises_message(
+ sa_exc.ArgumentError,
+ "Error creating backref",
+ configure_mappers
+ )
diff --git a/test/orm/test_manytomany.py b/test/orm/test_manytomany.py
index 1b5c5f7ac..d891e319e 100644
--- a/test/orm/test_manytomany.py
+++ b/test/orm/test_manytomany.py
@@ -90,7 +90,7 @@ class M2MTest(_base.MappedTest):
'places':relationship(Place, secondary=place_input, backref='transitions')
})
assert_raises_message(sa.exc.ArgumentError, "Error creating backref",
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_circular(self):
diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py
index 8360d54bf..7d12a8bab 100644
--- a/test/orm/test_mapper.py
+++ b/test/orm/test_mapper.py
@@ -7,7 +7,7 @@ from sqlalchemy import MetaData, Integer, String, ForeignKey, func, util
from sqlalchemy.test.schema import Table, Column
from sqlalchemy.engine import default
from sqlalchemy.orm import mapper, relationship, backref, \
- create_session, class_mapper, compile_mappers, reconstructor, \
+ create_session, class_mapper, configure_mappers, reconstructor, \
validates, aliased, Mapper
from sqlalchemy.orm import defer, deferred, synonym, attributes, \
column_property, composite, relationship, dynamic_loader, \
@@ -29,7 +29,7 @@ class MapperTest(_fixtures.FixtureTest):
properties={
'addresses':relationship(Address, backref='email_address')
})
- assert_raises(sa.exc.ArgumentError, sa.orm.compile_mappers)
+ assert_raises(sa.exc.ArgumentError, sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_update_attr_keys(self):
@@ -111,7 +111,7 @@ class MapperTest(_fixtures.FixtureTest):
"initialization of other mappers. "
"Original exception was: Class "
"'test.orm._fixtures.User' is not mapped$"
- , compile_mappers)
+ , configure_mappers)
@testing.resolve_artifact_names
def test_column_prefix(self):
@@ -137,23 +137,24 @@ class MapperTest(_fixtures.FixtureTest):
assert_raises(sa.exc.ArgumentError, mapper, User, s)
@testing.resolve_artifact_names
- def test_recompile_on_other_mapper(self):
- """A compile trigger on an already-compiled mapper still triggers a check against all mappers."""
+ def test_reconfigure_on_other_mapper(self):
+ """A configure trigger on an already-configured mapper
+ still triggers a check against all mappers."""
mapper(User, users)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
assert sa.orm.mapperlib._new_mappers is False
m = mapper(Address, addresses, properties={
'user': relationship(User, backref="addresses")})
- assert m.compiled is False
+ assert m.configured is False
assert sa.orm.mapperlib._new_mappers is True
u = User()
assert User.addresses
assert sa.orm.mapperlib._new_mappers is False
@testing.resolve_artifact_names
- def test_compile_on_session(self):
+ def test_configure_on_session(self):
m = mapper(User, users)
session = create_session()
session.connection(m)
@@ -198,25 +199,25 @@ class MapperTest(_fixtures.FixtureTest):
def test_props(self):
m = mapper(User, users, properties = {
'addresses' : relationship(mapper(Address, addresses))
- }).compile()
+ })
assert User.addresses.property is m.get_property('addresses')
@testing.resolve_artifact_names
- def test_compile_on_prop_1(self):
+ def test_configure_on_prop_1(self):
mapper(User, users, properties = {
'addresses' : relationship(mapper(Address, addresses))
})
User.addresses.any(Address.email_address=='foo@bar.com')
@testing.resolve_artifact_names
- def test_compile_on_prop_2(self):
+ def test_configure_on_prop_2(self):
mapper(User, users, properties = {
'addresses' : relationship(mapper(Address, addresses))
})
eq_(str(User.id == 3), str(users.c.id==3))
@testing.resolve_artifact_names
- def test_compile_on_prop_3(self):
+ def test_configure_on_prop_3(self):
class Foo(User):pass
mapper(User, users)
mapper(Foo, addresses, inherits=User)
@@ -226,24 +227,35 @@ class MapperTest(_fixtures.FixtureTest):
def test_deferred_subclass_attribute_instrument(self):
class Foo(User):pass
mapper(User, users)
- compile_mappers()
+ configure_mappers()
mapper(Foo, addresses, inherits=User)
assert getattr(Foo().__class__, 'name').impl is not None
@testing.resolve_artifact_names
- def test_compile_on_get_props_1(self):
+ def test_configure_on_get_props_1(self):
m =mapper(User, users)
- assert not m.compiled
+ assert not m.configured
assert list(m.iterate_properties)
- assert m.compiled
+ assert m.configured
@testing.resolve_artifact_names
- def test_compile_on_get_props_2(self):
+ def test_configure_on_get_props_2(self):
m= mapper(User, users)
- assert not m.compiled
+ assert not m.configured
assert m.get_property('name')
- assert m.compiled
+ assert m.configured
+
+ @testing.resolve_artifact_names
+ def test_configure_on_get_props_3(self):
+ m= mapper(User, users)
+ assert not m.configured
+ configure_mappers()
+
+ m2 = mapper(Address, addresses, properties={
+ 'user':relationship(User, backref='addresses')
+ })
+ assert m.get_property('addresses')
@testing.resolve_artifact_names
def test_add_property(self):
@@ -348,7 +360,7 @@ class MapperTest(_fixtures.FixtureTest):
mapper(Address, addresses, properties={
'user':synonym('_user')
})
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
# later, backref sets up the prop
mapper(User, users, properties={
@@ -391,13 +403,14 @@ class MapperTest(_fixtures.FixtureTest):
def test_illegal_non_primary(self):
mapper(User, users)
mapper(Address, addresses)
+ mapper(User, users, non_primary=True, properties={
+ 'addresses':relationship(Address)
+ })
assert_raises_message(
sa.exc.ArgumentError,
"Attempting to assign a new relationship 'addresses' "
"to a non-primary mapper on class 'User'",
- mapper(User, users, non_primary=True, properties={
- 'addresses':relationship(Address)
- }).compile
+ configure_mappers
)
@testing.resolve_artifact_names
@@ -469,7 +482,7 @@ class MapperTest(_fixtures.FixtureTest):
exclude_properties=(t.c.boss_id,
'employee_number', t.c.vendor_id))
- p_m.compile()
+ configure_mappers()
def assert_props(cls, want):
have = set([n for n in dir(cls) if not n.startswith('_')])
@@ -554,7 +567,7 @@ class MapperTest(_fixtures.FixtureTest):
addresses.join(email_bounces),
properties={'id':[addresses.c.id, email_bounces.c.id]}
)
- m.compile()
+ configure_mappers()
assert addresses in m._pks_by_table
assert email_bounces not in m._pks_by_table
@@ -986,25 +999,25 @@ class MapperTest(_fixtures.FixtureTest):
class MyFakeProperty(sa.orm.properties.ColumnProperty):
def post_instrument_class(self, mapper):
super(MyFakeProperty, self).post_instrument_class(mapper)
- m2.compile()
+ configure_mappers()
m1 = mapper(User, users, properties={
'name':MyFakeProperty(users.c.name)
})
m2 = mapper(Address, addresses)
- compile_mappers()
+ configure_mappers()
sa.orm.clear_mappers()
class MyFakeProperty(sa.orm.properties.ColumnProperty):
def post_instrument_class(self, mapper):
super(MyFakeProperty, self).post_instrument_class(mapper)
- m1.compile()
+ configure_mappers()
m1 = mapper(User, users, properties={
'name':MyFakeProperty(users.c.name)
})
m2 = mapper(Address, addresses)
- compile_mappers()
+ configure_mappers()
@testing.resolve_artifact_names
def test_reconstructor(self):
@@ -1087,7 +1100,7 @@ class MapperTest(_fixtures.FixtureTest):
'addresses':relationship(Address)
})
- assert_raises(sa.orm.exc.UnmappedClassError, sa.orm.compile_mappers)
+ assert_raises(sa.orm.exc.UnmappedClassError, sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_unmapped_subclass_error_postmap(self):
@@ -1097,7 +1110,7 @@ class MapperTest(_fixtures.FixtureTest):
pass
mapper(Base, users)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
# we can create new instances, set attributes.
s = Sub()
@@ -1122,7 +1135,7 @@ class MapperTest(_fixtures.FixtureTest):
class Sub(Base):
pass
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
# we can create new instances, set attributes.
s = Sub()
@@ -1186,7 +1199,7 @@ class DocumentTest(testing.TestBase):
'hoho':synonym("col4", doc="syn of col4")
})
mapper(Bar, t2)
- compile_mappers()
+ configure_mappers()
eq_(Foo.col1.__doc__, "primary key column")
eq_(Foo.col2.__doc__, "data col")
eq_(Foo.col5.__doc__, None)
diff --git a/test/orm/test_pickled.py b/test/orm/test_pickled.py
index 5b87b2b85..f23bc92a1 100644
--- a/test/orm/test_pickled.py
+++ b/test/orm/test_pickled.py
@@ -8,7 +8,7 @@ from sqlalchemy.test.schema import Table, Column
from sqlalchemy.orm import mapper, relationship, create_session, \
sessionmaker, attributes, interfaces,\
clear_mappers, exc as orm_exc,\
- compile_mappers
+ configure_mappers
from test.orm import _base, _fixtures
diff --git a/test/orm/test_query.py b/test/orm/test_query.py
index cbb77a53d..b20c783d4 100644
--- a/test/orm/test_query.py
+++ b/test/orm/test_query.py
@@ -57,7 +57,7 @@ class QueryTest(_fixtures.FixtureTest):
mapper(CompositePk, composite_pk_table)
- compile_mappers()
+ configure_mappers()
class RowTupleTest(QueryTest):
run_setup_mappers = None
diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py
index 5033a84fe..2ad8bc8aa 100644
--- a/test/orm/test_relationships.py
+++ b/test/orm/test_relationships.py
@@ -5,7 +5,7 @@ from sqlalchemy.test import testing
from sqlalchemy import Integer, String, ForeignKey, MetaData, and_
from sqlalchemy.test.schema import Table, Column
from sqlalchemy.orm import mapper, relationship, relation, \
- backref, create_session, compile_mappers, \
+ backref, create_session, configure_mappers, \
clear_mappers, sessionmaker, attributes,\
Session, composite, column_property
from sqlalchemy.test.testing import eq_, startswith_
@@ -420,7 +420,7 @@ class FKsAsPksTest(_base.MappedTest):
'b':relationship(B, cascade="all,delete-orphan", uselist=False)})
mapper(B, tableB)
- compile_mappers()
+ configure_mappers()
assert A.b.property.strategy.use_get
sess = create_session()
@@ -927,7 +927,7 @@ class ManualBackrefTest(_fixtures.FixtureTest):
'user':relationship(User, back_populates='addresses')
})
- assert_raises(sa.exc.InvalidRequestError, compile_mappers)
+ assert_raises(sa.exc.InvalidRequestError, configure_mappers)
@testing.resolve_artifact_names
def test_invalid_target(self):
@@ -945,7 +945,7 @@ class ManualBackrefTest(_fixtures.FixtureTest):
"User.addresses references "
"relationship Address.dingaling, which does not "
"reference mapper Mapper\|User\|users",
- compile_mappers)
+ configure_mappers)
class JoinConditionErrorTest(testing.TestBase):
@@ -961,7 +961,7 @@ class JoinConditionErrorTest(testing.TestBase):
c1id = Column('c1id', Integer, ForeignKey('c1.id'))
c2 = relationship(C1, primaryjoin=C1.id)
- assert_raises(sa.exc.ArgumentError, compile_mappers)
+ assert_raises(sa.exc.ArgumentError, configure_mappers)
def test_clauseelement_pj_false(self):
from sqlalchemy.ext.declarative import declarative_base
@@ -975,7 +975,7 @@ class JoinConditionErrorTest(testing.TestBase):
c1id = Column('c1id', Integer, ForeignKey('c1.id'))
c2 = relationship(C1, primaryjoin="x"=="y")
- assert_raises(sa.exc.ArgumentError, compile_mappers)
+ assert_raises(sa.exc.ArgumentError, configure_mappers)
def test_only_column_elements(self):
m = MetaData()
@@ -994,7 +994,7 @@ class JoinConditionErrorTest(testing.TestBase):
mapper(C1, t1, properties={'c2':relationship(C2,
primaryjoin=t1.join(t2))})
mapper(C2, t2)
- assert_raises(sa.exc.ArgumentError, compile_mappers)
+ assert_raises(sa.exc.ArgumentError, configure_mappers)
def test_invalid_string_args(self):
from sqlalchemy.ext.declarative import declarative_base
@@ -1025,7 +1025,7 @@ class JoinConditionErrorTest(testing.TestBase):
"Column-based expression object expected "
"for argument '%s'; got: '%s', type %r" %
(argname, arg[0], type(arg[0])),
- compile_mappers)
+ configure_mappers)
def test_fk_error_raised(self):
@@ -1051,7 +1051,7 @@ class JoinConditionErrorTest(testing.TestBase):
mapper(C1, t1, properties={'c2':relationship(C2)})
mapper(C2, t3)
- assert_raises(sa.exc.NoReferencedColumnError, compile_mappers)
+ assert_raises(sa.exc.NoReferencedColumnError, configure_mappers)
def test_join_error_raised(self):
m = MetaData()
@@ -1075,7 +1075,7 @@ class JoinConditionErrorTest(testing.TestBase):
mapper(C1, t1, properties={'c2':relationship(C2)})
mapper(C2, t3)
- assert_raises(sa.exc.ArgumentError, compile_mappers)
+ assert_raises(sa.exc.ArgumentError, configure_mappers)
def teardown(self):
clear_mappers()
@@ -1448,7 +1448,7 @@ class ViewOnlyLocalRemoteM2M(testing.TestBase):
b_plain= relationship( B, secondary=t12),
)
)
- compile_mappers()
+ configure_mappers()
assert m.get_property('b_view').local_remote_pairs == \
m.get_property('b_plain').local_remote_pairs == \
[(t1.c.id, t12.c.t1_id), (t2.c.id, t12.c.t2_id)]
@@ -1667,7 +1667,7 @@ class ViewOnlyComplexJoin(_base.MappedTest):
mapper(T3, t3)
assert_raises_message(sa.exc.ArgumentError,
"Specify remote_side argument",
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
class ExplicitLocalRemoteTest(_base.MappedTest):
@@ -1798,7 +1798,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
foreign_keys=[t2.c.t1id],
remote_side=[t2.c.t1id])})
mapper(T2, t2)
- assert_raises(sa.exc.ArgumentError, sa.orm.compile_mappers)
+ assert_raises(sa.exc.ArgumentError, sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_escalation_2(self):
@@ -1807,7 +1807,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest):
primaryjoin=t1.c.id==sa.func.lower(t2.c.t1id),
_local_remote_pairs=[(t1.c.id, t2.c.t1id)])})
mapper(T2, t2)
- assert_raises(sa.exc.ArgumentError, sa.orm.compile_mappers)
+ assert_raises(sa.exc.ArgumentError, sa.orm.configure_mappers)
class InvalidRemoteSideTest(_base.MappedTest):
@classmethod
@@ -1834,7 +1834,7 @@ class InvalidRemoteSideTest(_base.MappedTest):
"T1.t1s and back-reference T1.parent are "
"both of the same direction <symbol 'ONETOMANY>. Did you "
"mean to set remote_side on the many-to-one side ?",
- sa.orm.compile_mappers)
+ configure_mappers)
@testing.resolve_artifact_names
def test_m2o_backref(self):
@@ -1848,7 +1848,7 @@ class InvalidRemoteSideTest(_base.MappedTest):
"T1.t1s and back-reference T1.parent are "
"both of the same direction <symbol 'MANYTOONE>. Did you "
"mean to set remote_side on the many-to-one side ?",
- sa.orm.compile_mappers)
+ configure_mappers)
@testing.resolve_artifact_names
def test_o2m_explicit(self):
@@ -1861,7 +1861,7 @@ class InvalidRemoteSideTest(_base.MappedTest):
assert_raises_message(sa.exc.ArgumentError,
"both of the same direction <symbol 'ONETOMANY>. Did you "
"mean to set remote_side on the many-to-one side ?",
- sa.orm.compile_mappers)
+ configure_mappers)
@testing.resolve_artifact_names
def test_m2o_explicit(self):
@@ -1876,7 +1876,7 @@ class InvalidRemoteSideTest(_base.MappedTest):
assert_raises_message(sa.exc.ArgumentError,
"both of the same direction <symbol 'MANYTOONE>. Did you "
"mean to set remote_side on the many-to-one side ?",
- sa.orm.compile_mappers)
+ configure_mappers)
class InvalidRelationshipEscalationTest(_base.MappedTest):
@@ -1913,7 +1913,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Could not determine join condition between parent/child "
- "tables on relationship", sa.orm.compile_mappers)
+ "tables on relationship", sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_no_join_self_ref(self):
@@ -1924,7 +1924,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Could not determine join condition between parent/child "
- "tables on relationship", sa.orm.compile_mappers)
+ "tables on relationship", sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_no_equated(self):
@@ -1937,7 +1937,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
sa.exc.ArgumentError,
"Could not determine relationship direction "
"for primaryjoin condition",
- sa.orm.compile_mappers)
+ configure_mappers)
@testing.resolve_artifact_names
def test_no_equated_fks(self):
@@ -1950,7 +1950,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Could not locate any equated, locally mapped column pairs "
- "for primaryjoin condition", sa.orm.compile_mappers)
+ "for primaryjoin condition", sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_ambiguous_fks(self):
@@ -1973,7 +1973,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
"ForeignKeyConstraint objects "
r"established \(in which case "
r"'foreign_keys' is usually unnecessary\)\?"
- , sa.orm.compile_mappers)
+ , sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_ambiguous_remoteside_o2m(self):
@@ -1989,7 +1989,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"could not determine any local/remote column pairs",
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_ambiguous_remoteside_m2o(self):
@@ -2005,7 +2005,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"could not determine any local/remote column pairs",
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
@testing.resolve_artifact_names
@@ -2019,7 +2019,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
sa.exc.ArgumentError,
"Could not determine relationship direction for primaryjoin "
"condition",
- sa.orm.compile_mappers)
+ configure_mappers)
@testing.resolve_artifact_names
def test_no_equated_self_ref(self):
@@ -2032,7 +2032,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Could not locate any equated, locally mapped column pairs "
- "for primaryjoin condition", sa.orm.compile_mappers)
+ "for primaryjoin condition", sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_no_equated_viewonly(self):
@@ -2045,7 +2045,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
assert_raises_message(sa.exc.ArgumentError,
'Could not determine relationship '
'direction for primaryjoin condition',
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
sa.orm.clear_mappers()
mapper(Foo, foos_with_fks, properties={
@@ -2053,7 +2053,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
primaryjoin=foos_with_fks.c.id>bars_with_fks.c.fid,
viewonly=True)})
mapper(Bar, bars_with_fks)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
@testing.resolve_artifact_names
def test_no_equated_self_ref_viewonly(self):
@@ -2071,7 +2071,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
"Column objects have a ForeignKey "
"present, or are otherwise part of a "
"ForeignKeyConstraint on their parent "
- "Table.", sa.orm.compile_mappers)
+ "Table.", sa.orm.configure_mappers)
sa.orm.clear_mappers()
mapper(Foo, foos_with_fks, properties={
@@ -2079,7 +2079,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
primaryjoin=foos_with_fks.c.id>foos_with_fks.c.fid,
viewonly=True)})
mapper(Bar, bars_with_fks)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
@testing.resolve_artifact_names
def test_no_equated_self_ref_viewonly_fks(self):
@@ -2089,7 +2089,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
viewonly=True,
foreign_keys=[foos.c.fid])})
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
eq_(Foo.foos.property.local_remote_pairs, [(foos.c.id, foos.c.fid)])
@testing.resolve_artifact_names
@@ -2103,14 +2103,14 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
sa.exc.ArgumentError,
"Could not determine relationship direction for primaryjoin "
"condition",
- sa.orm.compile_mappers)
+ configure_mappers)
sa.orm.clear_mappers()
mapper(Foo, foos_with_fks, properties={
'bars':relationship(Bar,
primaryjoin=foos_with_fks.c.id==bars_with_fks.c.fid)})
mapper(Bar, bars_with_fks)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
@testing.resolve_artifact_names
def test_equated_self_ref(self):
@@ -2122,7 +2122,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
sa.exc.ArgumentError,
"Could not determine relationship direction for primaryjoin "
"condition",
- sa.orm.compile_mappers)
+ configure_mappers)
@testing.resolve_artifact_names
@@ -2136,7 +2136,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest):
sa.exc.ArgumentError,
"Could not determine relationship direction for primaryjoin "
"condition",
- sa.orm.compile_mappers)
+ configure_mappers)
class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
@@ -2181,7 +2181,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Could not determine join condition between parent/child tables "
- "on relationship", sa.orm.compile_mappers)
+ "on relationship", sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_no_secondaryjoin(self):
@@ -2195,7 +2195,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
sa.exc.ArgumentError,
"Could not determine join condition between parent/child tables "
"on relationship",
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_no_fks_warning_1(self):
@@ -2212,7 +2212,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
"'foobars.bid', 'foobars.fid' for join "
"condition 'foos.id = foobars.fid' on "
"relationship Foo.bars",
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
sa.orm.clear_mappers()
mapper(Foo, foos, properties={
@@ -2237,7 +2237,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
"join condition 'foos.id = "
"foobars_with_many_columns.fid' on "
"relationship Foo.bars",
- sa.orm.compile_mappers)
+ sa.orm.configure_mappers)
@testing.emits_warning(r'No ForeignKey objects.*')
@testing.resolve_artifact_names
@@ -2247,7 +2247,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
primaryjoin=foos.c.id==foobars.c.fid,
secondaryjoin=foobars.c.bid==bars.c.id)})
mapper(Bar, bars)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
eq_(
Foo.bars.property.synchronize_pairs,
[(foos.c.id, foobars.c.fid)]
@@ -2266,7 +2266,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
secondaryjoin=foobars_with_many_columns.c.bid==
bars.c.id)})
mapper(Bar, bars)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
eq_(
Foo.bars.property.synchronize_pairs,
[(foos.c.id, foobars_with_many_columns.c.fid)]
@@ -2290,7 +2290,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
sa.exc.ArgumentError,
"Could not determine relationship direction for "
"primaryjoin condition",
- sa.orm.compile_mappers)
+ configure_mappers)
sa.orm.clear_mappers()
mapper(Foo, foos, properties={
@@ -2303,7 +2303,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
sa.exc.ArgumentError,
"Could not locate any equated, locally mapped column pairs for "
"primaryjoin condition ",
- sa.orm.compile_mappers)
+ configure_mappers)
sa.orm.clear_mappers()
mapper(Foo, foos, properties={
@@ -2313,7 +2313,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
secondaryjoin=foobars_with_fks.c.bid<=bars.c.id,
viewonly=True)})
mapper(Bar, bars)
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
@testing.resolve_artifact_names
def test_bad_secondaryjoin(self):
@@ -2338,7 +2338,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
"ForeignKey and/or ForeignKeyConstraint "
r"objects established \(in which case "
r"'foreign_keys' is usually unnecessary\)?"
- , sa.orm.compile_mappers)
+ , sa.orm.configure_mappers)
@testing.resolve_artifact_names
def test_no_equated_secondaryjoin(self):
@@ -2353,7 +2353,7 @@ class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
assert_raises_message(
sa.exc.ArgumentError,
"Could not locate any equated, locally mapped column pairs for "
- "secondaryjoin condition", sa.orm.compile_mappers)
+ "secondaryjoin condition", sa.orm.configure_mappers)
class ActiveHistoryFlagTest(_fixtures.FixtureTest):
run_inserts = None
diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py
index 61ef52bdd..00ca36b07 100644
--- a/test/orm/test_unitofwork.py
+++ b/test/orm/test_unitofwork.py
@@ -684,7 +684,7 @@ class ForeignPKTest(_base.MappedTest):
m2 = mapper(Person, people, properties={
'sites' : relationship(PersonSite)})
- sa.orm.compile_mappers()
+ sa.orm.configure_mappers()
eq_(list(m2.get_property('sites').synchronize_pairs),
[(people.c.person, peoplesites.c.person)])
@@ -861,7 +861,7 @@ class PassiveDeletesTest(_base.MappedTest):
'myclass':relationship(MyClass, cascade="all, delete", passive_deletes=True)
})
mapper(MyClass, mytable)
- assert_raises(sa.exc.SAWarning, sa.orm.compile_mappers)
+ assert_raises(sa.exc.SAWarning, sa.orm.configure_mappers)
class ExtraPassiveDeletesTest(_base.MappedTest):
__requires__ = ('foreign_keys',)