summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-02-09 15:56:21 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-02-09 15:56:21 -0500
commita925565f99610e5279f691f03e50deef5e042061 (patch)
treed13c46b4ecf58a71ec171e370a4d3765aac421a2 /examples
parent6fb9f826e992f3ca4e5d4b95ef6d30aebb9c7558 (diff)
downloadsqlalchemy-a925565f99610e5279f691f03e50deef5e042061.tar.gz
declarartive reflection example didn't actually work for single inheritance, added a tweak to make that possible
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative_reflection/declarative_reflection.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/declarative_reflection/declarative_reflection.py b/examples/declarative_reflection/declarative_reflection.py
index 42d2201e1..372149317 100644
--- a/examples/declarative_reflection/declarative_reflection.py
+++ b/examples/declarative_reflection/declarative_reflection.py
@@ -1,5 +1,6 @@
from sqlalchemy import *
from sqlalchemy.orm import *
+from sqlalchemy.orm.util import _is_mapped_class
from sqlalchemy.ext.declarative import declarative_base, declared_attr
class DeclarativeReflectedBase(object):
@@ -35,6 +36,16 @@ class DeclarativeReflectedBase(object):
autoload=True,
autoload_with=engine,
schema=table.schema)
+
+ # see if we need 'inherits' in the
+ # mapper args. Declarative will have
+ # skipped this since mappings weren't
+ # available yet.
+ for c in klass.__bases__:
+ if _is_mapped_class(c):
+ kw['inherits'] = c
+ break
+
klass.__mapper__ = mapper(*args, **kw)
if __name__ == '__main__':