From: Mike Bayer Date: Sun, 29 Oct 2006 02:12:05 +0000 (+0000) Subject: added assertion to check that mappers only inherit from a mapper with the same "prima... X-Git-Tag: rel_0_3_1~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=944f12bad027d01230b07d0d447d325d747f3897;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git added assertion to check that mappers only inherit from a mapper with the same "primary/non-primary" setting --- diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index bd5f4c7ec5..4fcc7d14c7 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -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