Commits

Mike Bayer committed 4208614

- the versioning example works correctly now
if versioning on a col that was formerly
NULL.

Comments (0)

Files changed (3)

     by the versioning example is deprecated; 
     now use mapper.get_property_by_column() which 
     will remain the public method for this.
+
+  - the versioning example works correctly now
+    if versioning on a col that was formerly 
+    NULL.
     
 - sql
   - Added basic math expression coercion for 

examples/versioning/history_meta.py

             elif u:
                 attr[hist_col.key] = u[0]
             else:
-                assert False, "Attribute had no previous state. "\
-                            "This indicates active_history isn't "\
-                            "working as expected."
+                # if the attribute had no value.
+                attr[hist_col.key] = a[0]
+                obj_changed = True
                 
     if not obj_changed and not deleted:            
         return

examples/versioning/test_versioning.py

             ]
         )
 
-
-
+    def test_from_null(self):
+        class SomeClass(Base, ComparableEntity):
+            __tablename__ = 'sometable'
+            
+            id = Column(Integer, primary_key=True)
+            name = Column(String(50))
+        
+        self.create_tables()
+        sess = Session()
+        sc = SomeClass()
+        sess.add(sc)
+        sess.commit()
+        
+        sc.name = 'sc1'
+        sess.commit()
+        
+        assert sc.version == 2
 
     def test_deferred(self):
         """test versioning of unloaded, deferred columns."""