diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-05-17 11:45:05 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-05-17 11:45:05 -0400 |
| commit | 29251675503271fc700a6f7655157850e2de426d (patch) | |
| tree | 0a6f5a43525fc2e5390716812e511893cc8e9ce7 /lib/sqlalchemy/ext | |
| parent | da8032dc45ad8243323e9359f9b31efe1b7cfe5b (diff) | |
| download | sqlalchemy-29251675503271fc700a6f7655157850e2de426d.tar.gz | |
- [feature] The "deferred declarative
reflection" system has been moved into the
declarative extension itself, using the
new DeferredReflection class. This
class is now tested with both single
and joined table inheritance use cases.
[ticket:2485]
- [bug] The autoload_replace flag on Table,
when False, will cause any reflected foreign key
constraints which refer to already-declared
columns to be skipped, assuming that the
in-Python declared column will take over
the task of specifying in-Python ForeignKey
or ForeignKeyConstraint declarations.
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rwxr-xr-x | lib/sqlalchemy/ext/declarative.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 93df1c593..2e9012384 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -325,12 +325,13 @@ in conjunction with a mapped class:: However, one improvement that can be made here is to not require the :class:`.Engine` to be available when classes are -being first declared. To achieve this, use the example -described at :ref:`examples_declarative_reflection` to build a -declarative base that sets up mappings only after a special -``prepare(engine)`` step is called:: +being first declared. To achieve this, use the +:class:`.DeferredReflection` mixin, which sets up mappings +only after a special ``prepare(engine)`` step is called:: - Base = declarative_base(cls=DeclarativeReflectedBase) + from sqlalchemy.ext.declarative import declarative_base, DeferredReflection + + Base = declarative_base(cls=DeferredReflection) class Foo(Base): __tablename__ = 'foo' @@ -346,7 +347,9 @@ declarative base that sets up mappings only after a special Base.prepare(e) - +.. versionadded:: 0.8 + Added :class:`.DeferredReflection`. + Mapper Configuration ==================== @@ -1871,8 +1874,8 @@ class DeferredReflection(object): def prepare(cls, engine): """Reflect all :class:`.Table` objects for all current :class:`.DeferredReflection` subclasses""" - to_map = set([m for m in _MapperConfig.configs.values() - if issubclass(m.cls, cls)]) + to_map = [m for m in _MapperConfig.configs.values() + if issubclass(m.cls, cls)] for thingy in to_map: cls.__prepare__(thingy.args, engine) thingy.map() |
