diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-29 23:53:10 -0600 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-30 21:06:27 -0600 |
commit | 147f6d382c3b6f06c8efa5a24c07c9849473e7af (patch) | |
tree | b3c1288d8d493bba638a3b07fd2bfdc7defa8fa6 /lib/sqlalchemy/ext/automap.py | |
parent | b8f9517cddf41dbb47ae4ad120141c7ab1a29ac5 (diff) | |
download | sqlalchemy-147f6d382c3b6f06c8efa5a24c07c9849473e7af.tar.gz |
Add informative failure modes to _DeferredMapperConfig
Added some helper exceptions that invoke when a mapping based on
:class:`.AbstractConcreteBase`, :class:`.DeferredReflection`, or
:class:`.AutoMap` is used before the mapping is ready to be used, which
contain descriptive information on the class, rather than falling through
into other failure modes that are less informative.
Fixes: #4470
Change-Id: I9bc51697f63cedaa7809a0adb17b2398c209e289
Diffstat (limited to 'lib/sqlalchemy/ext/automap.py')
-rw-r--r-- | lib/sqlalchemy/ext/automap.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py index 55ab325a3..5fa4e8822 100644 --- a/lib/sqlalchemy/ext/automap.py +++ b/lib/sqlalchemy/ext/automap.py @@ -517,6 +517,7 @@ from .declarative import declarative_base as _declarative_base from .declarative.base import _DeferredMapperConfig from .. import util from ..orm import backref +from ..orm import exc as orm_exc from ..orm import interfaces from ..orm import relationship from ..orm.mapper import _CONFIGURE_MUTEX @@ -841,6 +842,16 @@ class AutomapBase(object): """ + @classmethod + def _sa_raise_deferred_config(cls): + raise orm_exc.UnmappedClassError( + cls, + msg="Class %s is a subclass of AutomapBase. " + "Mappings are not produced until the .prepare() " + "method is called on the class hierarchy." + % orm_exc._safe_cls_name(cls), + ) + def automap_base(declarative_base=None, **kw): r"""Produce a declarative automap base. |