]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
inheritance check uses issubclass() instead of direct __mro__ check
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Aug 2006 19:16:27 +0000 (19:16 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Aug 2006 19:16:27 +0000 (19:16 +0000)
to make sure class A inherits from B, allowing mapper inheritance to more
flexibly correspond to class inheritance [ticket:271]

CHANGES
lib/sqlalchemy/orm/mapper.py

diff --git a/CHANGES b/CHANGES
index d88339419e5db9c5425902f59f2c87143d528b24..de8aa22cefb10cc02371504371eed03ff2375be1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -30,6 +30,9 @@ return an array instead of string for SHOW CREATE TABLE call
 "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
index 4db2b40f213dde2aad470f19bcc6395e831d25c3..d4d7479598b8f20d6201bbc0359e936707c373b3 100644 (file)
@@ -228,7 +228,7 @@ class Mapper(object):
                 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: