From: Mike Bayer Date: Sat, 27 Jan 2007 21:30:35 +0000 (+0000) Subject: - fix for multi-level polymorphic mappers X-Git-Tag: rel_0_3_5~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ffaf5603f2e860ec29f3463407c477dc3b1fec4;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - fix for multi-level polymorphic mappers --- diff --git a/CHANGES b/CHANGES index 6fdd407136..140139987a 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ will match up on straight column names (i.e. its a more liberal policy) - eager relation to an inheriting mapper wont fail if no rows returned for the relationship. + - fix for multi-level polymorphic mappers - oracle: - when returning "rowid" as the ORDER BY column or in use with ROW_NUMBER OVER, oracle dialect checks the selectable its being applied to and will switch to diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 4cdf62227d..e0ee36fac6 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1149,19 +1149,19 @@ class Mapper(object): this mapper is the same mapper as 'self' unless the select_table argument was specified for this mapper.""" return self.__surrogate_mapper or self - def _instance(self, context, row, result = None): + def _instance(self, context, row, result = None, skip_polymorphic=False): """pulls an object instance from the given row and appends it to the given result list. if the instance already exists in the given identity map, its not added. in either case, executes all the property loaders on the instance to also process extra information in the row.""" - if self.polymorphic_on is not None: + if not skip_polymorphic and self.polymorphic_on is not None: discriminator = row[self.polymorphic_on] if discriminator is not None: mapper = self.polymorphic_map[discriminator] if mapper is not self: row = self.translate_row(mapper, row) - return mapper._instance(context, row, result=result) + return mapper._instance(context, row, result=result, skip_polymorphic=True) # look in main identity map. if its there, we dont do anything to it, # including modifying any of its related items lists, as its already