From 3ffa0bda31e2e590ff28f1bb1cccccda010b4462 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 18 Apr 2006 18:24:07 +0000 Subject: [PATCH] mapper will verify class inheritance scheme; also will not re-init inherited property, as the improved attribute system seems to handle inheritance OK and allows the property to keep its correct initialization on the parent exceptions import in query --- lib/sqlalchemy/mapping/mapper.py | 4 +++- lib/sqlalchemy/mapping/query.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/mapping/mapper.py b/lib/sqlalchemy/mapping/mapper.py index 80b5680a34..302cb17411 100644 --- a/lib/sqlalchemy/mapping/mapper.py +++ b/lib/sqlalchemy/mapping/mapper.py @@ -88,6 +88,8 @@ class Mapper(object): self.table = table if inherits is not None: + if self.class_.__mro__[1] != inherits.class_: + raise ArgumentError("Class '%s' does not inherit from '%s'" % (self.class_.__name__, inherits.class_.__name__)) self.primarytable = inherits.primarytable # inherit_condition is optional. if not table is inherits.noninherited_table: @@ -214,7 +216,7 @@ class Mapper(object): if not self.props.has_key(key): self.props[key] = prop.copy() self.props[key].parent = self - self.props[key].key = None # force re-init + # self.props[key].key = None # force re-init l = [(key, prop) for key, prop in self.props.iteritems()] for key, prop in l: if getattr(prop, 'key', None) is None: diff --git a/lib/sqlalchemy/mapping/query.py b/lib/sqlalchemy/mapping/query.py index 72037a347d..8233fba654 100644 --- a/lib/sqlalchemy/mapping/query.py +++ b/lib/sqlalchemy/mapping/query.py @@ -9,6 +9,7 @@ import objectstore import sqlalchemy.sql as sql import sqlalchemy.util as util import mapper +from sqlalchemy.exceptions import * class Query(object): """encapsulates the object-fetching operations provided by Mappers.""" -- 2.47.2