summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-02-21 21:41:53 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-02-21 21:41:53 +0000
commit65da266daaaaed26c5d141bad1eda2600c597da4 (patch)
treebcde345ccde4e91122ce680644d064df2e276435 /lib/sqlalchemy
parent334668d904ae31eea6bf8d7035f9088c69df78ee (diff)
downloadsqlalchemy-65da266daaaaed26c5d141bad1eda2600c597da4.tar.gz
- preventive code against a potential lost-reference
bug in flush()
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index 0f87d7308..cd6254b22 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -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)