Commits

Mike Bayer committed 8c999fe

- Fixed bug whereby list-based attributes, like pickletype
and PGArray, failed to be merged() properly.

Comments (0)

Files changed (3)

       so applications which relied on this erroneous result need to be 
       adjusted. [ticket:1431]
 
+    - Fixed bug whereby list-based attributes, like pickletype
+      and PGArray, failed to be merged() properly.
+      
     - The "foreign_keys" argument of relation() will now propagate
       automatically to the backref in the same way that
       primaryjoin and secondaryjoin do.   For the extremely 

lib/sqlalchemy/orm/state.py

             return None
         elif hasattr(impl, 'get_collection'):
             return impl.get_collection(self, dict_, x, passive=passive)
-        elif isinstance(x, list):
-            return x
         else:
             return [x]
 

test/orm/test_merge.py

 from sqlalchemy.test.testing import assert_raises, assert_raises_message
 import sqlalchemy as sa
+from sqlalchemy import Table, Column, Integer, PickleType
+import operator
 from sqlalchemy.test import testing
 from sqlalchemy.util import OrderedSet
-from sqlalchemy.orm import mapper, relation, create_session, PropComparator, synonym, comparable_property
+from sqlalchemy.orm import mapper, relation, create_session, PropComparator, synonym, comparable_property, sessionmaker
 from sqlalchemy.test.testing import eq_, ne_
 from test.orm import _base, _fixtures
 
 
 class MergeTest(_fixtures.FixtureTest):
-    """Session..merge() functionality"""
+    """Session.merge() functionality"""
 
     run_inserts = None
 
         sess.commit()
 
 
+class MutableMergeTest(_base.MappedTest):
+    @classmethod
+    def define_tables(cls, metadata):
+        Table("data", metadata, 
+            Column('id', Integer, primary_key=True),
+            Column('data', PickleType(comparator=operator.eq))
+        )
+    
+    @classmethod
+    def setup_classes(cls):
+        class Data(_base.ComparableEntity):
+            pass
+    
+    @testing.resolve_artifact_names
+    def test_list(self):
+        mapper(Data, data)
+        sess = sessionmaker()()
+        d = Data(data=["this", "is", "a", "list"])
+        
+        sess.add(d)
+        sess.commit()
+        
+        d2 = Data(id=d.id, data=["this", "is", "another", "list"])
+        d3 = sess.merge(d2)
+        eq_(d3.data, ["this", "is", "another", "list"])
+        
+        
+        
+        
 
-