From b1fb11dda0454ca9738338e7cc549547c158222b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 31 Mar 2012 12:55:42 -0400 Subject: - [bug] Fixed bug whereby polymorphic_on column that's not otherwise mapped on the class would be incorrectly included in a merge() operation, raising an error. [ticket:2449] --- lib/sqlalchemy/orm/properties.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py index 59c4cb3dc..74ccf0157 100644 --- a/lib/sqlalchemy/orm/properties.py +++ b/lib/sqlalchemy/orm/properties.py @@ -136,7 +136,9 @@ class ColumnProperty(StrategizedProperty): def merge(self, session, source_state, source_dict, dest_state, dest_dict, load, _recursive): - if self.key in source_dict: + if not self.instrument: + return + elif self.key in source_dict: value = source_dict[self.key] if not load: @@ -144,9 +146,8 @@ class ColumnProperty(StrategizedProperty): else: impl = dest_state.get_impl(self.key) impl.set(dest_state, dest_dict, value, None) - else: - if dest_state.has_identity and self.key not in dest_dict: - dest_state.expire_attributes(dest_dict, [self.key]) + elif dest_state.has_identity and self.key not in dest_dict: + dest_state.expire_attributes(dest_dict, [self.key]) class Comparator(PropComparator): @util.memoized_instancemethod -- cgit v1.2.1