]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added assertion to check that mappers only inherit from a mapper with the same "prima...
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 29 Oct 2006 02:12:05 +0000 (02:12 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 29 Oct 2006 02:12:05 +0000 (02:12 +0000)
lib/sqlalchemy/orm/mapper.py

index bd5f4c7ec522dec92f839c6a7681b282c4a36c50..4fcc7d14c7b20e1ba97a0ee658ff33b7025df6b7 100644 (file)
@@ -315,6 +315,9 @@ class Mapper(object):
                 self.inherits = self.inherits._do_compile()
             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__))
+            if self._is_primary_mapper() != self.inherits._is_primary_mapper():
+                np = self._is_primary_mapper() and "primary" or "non-primary"
+                raise exceptions.ArgumentError("Inheritance of %s mapper for class '%s' is only allowed from a %s mapper" % (np, self.class_.__name__, np))
             # inherit_condition is optional.
             if self.local_table is None:
                 self.local_table = self.inherits.local_table