From: Mike Bayer Date: Thu, 9 Feb 2012 20:56:21 +0000 (-0500) Subject: declarartive reflection example didn't actually work for single inheritance, added... X-Git-Tag: rel_0_7_6~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a925565f99610e5279f691f03e50deef5e042061;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git declarartive reflection example didn't actually work for single inheritance, added a tweak to make that possible --- diff --git a/examples/declarative_reflection/declarative_reflection.py b/examples/declarative_reflection/declarative_reflection.py index 42d2201e1e..3721493172 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__':