- Some adjustments to Session.identity_map's weak referencing
behavior to reduce asynchronous GC side effects.
+
+ - Adjustment to Session's post-flush accounting of newly
+ "clean" objects to better protect against operating on
+ objects as they're asynchronously gc'ed. [ticket:1182]
- sql
- column.in_(someselect) can now be used as a columns-clause
def _register_newly_persistent(self, state):
mapper = _state_mapper(state)
- instance_key = mapper._identity_key_from_state(state)
- if state.key is None:
- state.key = instance_key
- elif state.key != instance_key:
- # primary key switch
- self.identity_map.remove(state)
- state.key = instance_key
-
- obj = state.obj()
# prevent against last minute dereferences of the object
- # TODO: identify a code path where state.obj() is None
+ obj = state.obj()
if obj is not None:
+
+ instance_key = mapper._identity_key_from_state(state)
+
+ if state.key is None:
+ state.key = instance_key
+ elif state.key != instance_key:
+ # primary key switch
+ self.identity_map.remove(state)
+ state.key = instance_key
+
if state.key in self.identity_map and not self.identity_map.contains_state(state):
self.identity_map.remove_key(state.key)
self.identity_map.add(state)
except:
transaction.rollback()
raise
-
+
flush_context.finalize_flush_changes()
if not objects: