- extra merge test

- merge with dont_load also propagates _state.modified
This commit is contained in:
Mike Bayer
2007-11-02 18:05:06 +00:00
parent 4161271a8c
commit d355ea021d
3 changed files with 13 additions and 1 deletions
-1
View File
@@ -292,7 +292,6 @@ class PropertyLoader(StrategizedProperty):
for current in list(childlist):
obj = session.merge(current, entity_name=self.mapper.entity_name, dont_load=dont_load, _recursive=_recursive)
if obj is not None:
#dest_list.append_without_event(obj)
dest_list.append_with_event(obj)
else:
current = list(childlist)[0]
+2
View File
@@ -879,6 +879,8 @@ class Session(object):
raise exceptions.AssertionError("Instance %s has an instance key but is not persisted" % mapperutil.instance_str(object))
for prop in mapper.iterate_properties:
prop.merge(self, object, merged, dont_load, _recursive)
if dont_load:
merged._state.modified = object._state.modified
if key is None:
self.save(merged, entity_name=mapper.entity_name)
return merged
+11
View File
@@ -117,6 +117,17 @@ class MergeTest(AssertMixin):
# no changes; therefore flush should do nothing
self.assert_sql_count(testbase.db, go, 0)
# pre merge change
u.user_name='fred3'
sess4 = create_session()
u = sess4.merge(u, dont_load=True)
# post merge change
u.addresses[1].email_address='afafds'
def go():
sess4.flush()
# changes still flush
self.assert_sql_count(testbase.db, go, 2)
def test_saved_cascade_2(self):
"""tests a more involved merge"""
mapper(Order, orders, properties={