]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed regression introduced in 0.6.0 involving improper
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Apr 2010 20:55:11 +0000 (16:55 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Apr 2010 20:55:11 +0000 (16:55 -0400)
history accounting on mutable attributes.  Essentially
reversing r6b2b4fcd4799 and getting it covered.
[ticket:1782]

CHANGES
lib/sqlalchemy/orm/attributes.py
test/orm/test_unitofwork.py

diff --git a/CHANGES b/CHANGES
index 2ae0415a935cab55a12f840a6c0f61e2ef419a19..9cdae0c81b534c5297cbfeaa6a90bd90f79dbaf5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,10 @@ CHANGES
 =======
 0.6.1
 =====
+- orm
+  - Fixed regression introduced in 0.6.0 involving improper
+    history accounting on mutable attributes.  [ticket:1782]
+    
 - sql
   - Fixed bug that prevented implicit RETURNING from functioning
     properly with composite primary key that contained zeroes.
index 5ac8ef9ee4733874c69d1e8dc3b10987fc4697d4..4390538a0224dd732a78a659bbe851d9e440276e 100644 (file)
@@ -500,8 +500,7 @@ class MutableScalarAttributeImpl(ScalarAttributeImpl):
             self, state, v)
 
     def check_mutable_modified(self, state, dict_):
-        v = dict_.get(self.key, NO_VALUE)
-        a, u, d = History.from_attribute(self, state, v)
+        a, u, d = self.get_history(state, dict_)
         return bool(a or d)
 
     def get(self, state, dict_, passive=PASSIVE_OFF):
index ba62ce07d182c748f42081a2d40f8c820010a0a7..ea63975178c2859e0cded49856a51c4ff0afe0fc 100644 (file)
@@ -11,7 +11,7 @@ from sqlalchemy.test import engines, testing, pickleable
 from sqlalchemy import Integer, String, ForeignKey, literal_column
 from sqlalchemy.test.schema import Table
 from sqlalchemy.test.schema import Column
-from sqlalchemy.orm import mapper, relationship, create_session, column_property
+from sqlalchemy.orm import mapper, relationship, create_session, column_property, attributes
 from sqlalchemy.test.testing import eq_, ne_
 from test.orm import _base, _fixtures
 from test.engine import _base as engine_base
@@ -344,6 +344,21 @@ class MutableTypesTest(_base.MappedTest):
 
         assert session.query(Foo).one().data == pickleable.Bar(4, 19)
 
+    @testing.resolve_artifact_names
+    def test_resurrect_two(self):
+        f1 = Foo()
+        f1.data = pickleable.Bar(4,5)
+        session = create_session(autocommit=False)
+        session.add(f1)
+        session.commit()
+        
+        session = create_session(autocommit=False)
+        f1 = session.query(Foo).first()
+        del f1 # modified flag flips by accident
+        gc.collect()
+        f1 = session.query(Foo).first()
+        assert not attributes.instance_state(f1).modified
+        
     @testing.resolve_artifact_names
     def test_unicode(self):
         """Equivalent Unicode values are not flagged as changed."""