From a925565f99610e5279f691f03e50deef5e042061 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 9 Feb 2012 15:56:21 -0500 Subject: [PATCH] declarartive reflection example didn't actually work for single inheritance, added a tweak to make that possible --- .../declarative_reflection/declarative_reflection.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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__': -- 2.47.2