]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- preventive code against a potential lost-reference
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 21 Feb 2008 21:41:53 +0000 (21:41 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 21 Feb 2008 21:41:53 +0000 (21:41 +0000)
bug in flush()

CHANGES
lib/sqlalchemy/orm/unitofwork.py

diff --git a/CHANGES b/CHANGES
index 988c0403d1ff3ff49e5c5c3f8da2402cda04ca9e..c9030a6ba8c37e004dea7a83e6d58b1d67a5b15c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -30,7 +30,10 @@ CHANGES
       
         query.join(Company.employees.of_type(Engineer)).
           filter(Engineer.name=='foo')
-      
+
+      - preventive code against a potential lost-reference 
+        bug in flush()
+        
 0.4.4
 ------
 
index 0f87d730878c4027a0a7280dd81385a88e1c3bb3..cd6254b22fc18f4175a377aa004518c45731a02a 100644 (file)
@@ -134,9 +134,13 @@ class UnitOfWork(object):
             
         if hasattr(state, 'insert_order'):
             delattr(state, 'insert_order')
-            
-        self.identity_map[state.dict['_instance_key']] = state.obj()
-        state.commit_all()
+        
+        o = state.obj()
+        # prevent against last minute dereferences of "dirty"
+        # objects TODO: identify a code path where state.obj() is None
+        if o is not None:
+            self.identity_map[state.dict['_instance_key']] = o
+            state.commit_all()
         
         # remove from new last, might be the last strong ref
         self.new.pop(state, None)