From: Mike Bayer Date: Sun, 5 Sep 2010 18:51:00 +0000 (-0400) Subject: - the versioning example works correctly now X-Git-Tag: rel_0_6_4~10^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc26030e6f4e5bdb50338b88b3eb4c888eb7bae0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - the versioning example works correctly now if versioning on a col that was formerly NULL. --- diff --git a/CHANGES b/CHANGES index 43b6336811..43cdb86ed9 100644 --- a/CHANGES +++ b/CHANGES @@ -164,6 +164,10 @@ CHANGES 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 diff --git a/examples/versioning/history_meta.py b/examples/versioning/history_meta.py index d2d7c12477..0a631e8492 100644 --- a/examples/versioning/history_meta.py +++ b/examples/versioning/history_meta.py @@ -144,9 +144,9 @@ def create_version(obj, session, deleted = False): 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 diff --git a/examples/versioning/test_versioning.py b/examples/versioning/test_versioning.py index 2a7a2ca668..031d7ca261 100644 --- a/examples/versioning/test_versioning.py +++ b/examples/versioning/test_versioning.py @@ -86,8 +86,23 @@ class TestVersioning(TestBase): ] ) - - + 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."""