Commits

Mike Bayer committed 06e5c81

inheritance check uses issubclass() instead of direct __mro__ check
to make sure class A inherits from B, allowing mapper inheritance to more
flexibly correspond to class inheritance [ticket:271]

  • Participants
  • Parent commits d438410

Comments (0)

Files changed (2)

 "engine" is deprecated.
 - fixed ms-sql connect() to work with adodbapi
 - added "nowait" flag to Select()
+- inheritance check uses issubclass() instead of direct __mro__ check
+to make sure class A inherits from B, allowing mapper inheritance to more 
+flexibly correspond to class inheritance [ticket:271]
 
 0.2.6
 - big overhaul to schema to allow truly composite primary and foreign

File lib/sqlalchemy/orm/mapper.py

                 self.inherits = class_mapper(self.inherits, compile=False)._do_compile()
             else:
                 self.inherits = self.inherits._do_compile()
-            if self.class_.__mro__[1] != self.inherits.class_:
+            if not issubclass(self.class_, self.inherits.class_):
                 raise exceptions.ArgumentError("Class '%s' does not inherit from '%s'" % (self.class_.__name__, self.inherits.class_.__name__))
             # inherit_condition is optional.
             if self.local_table is None: