Commits

Mike Bayer committed b498389

- [bug] Fixed bug in get_history() when referring
to a composite attribute that has no value;
added coverage for get_history() regarding
composites which is otherwise just a userland
function.

Comments (0)

Files changed (3)

     New example in the relationship docs illustrates
     its use.
 
+  - [bug] Fixed bug in get_history() when referring
+    to a composite attribute that has no value;
+    added coverage for get_history() regarding 
+    composites which is otherwise just a userland
+    function.
+
 - sql
    - [bug] related to [ticket:2316], made some 
      adjustments to the change from [ticket:2261]

lib/sqlalchemy/orm/descriptor_props.py

             if hist.has_changes():
                 has_history = True
 
-            added.extend(hist.non_deleted())
+            non_deleted = hist.non_deleted()
+            if non_deleted:
+                added.extend(non_deleted)
+            else:
+                added.append(None)
             if hist.deleted:
                 deleted.extend(hist.deleted)
             else:

test/orm/test_composites.py

             []
         )
 
+    def test_get_history(self):
+        Edge = self.classes.Edge
+        Point = self.classes.Point
+        from sqlalchemy.orm.attributes import get_history
+
+        e1 = Edge()
+        e1.start = Point(1,2)
+        eq_(
+            get_history(e1, 'start'),
+            ([Point(x=1, y=2)], (), [Point(x=None, y=None)])
+        )
+
+        eq_(
+            get_history(e1, 'end'),
+            ((), [Point(x=None, y=None)], ())
+        )
+
     def test_query_cols(self):
         Edge = self.classes.Edge