Skip to content

Commit

Permalink
A bit more aggressive cache clearing after rollback in interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Jan 5, 2019
1 parent b442cb3 commit aa16b4f
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pony/orm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,17 +1835,16 @@ def close(cache, rollback=True):
provider.release(connection, cache)
finally:
db_session = cache.db_session or local.db_session
if db_session:
if db_session.strict:
for obj in cache.objects:
obj._vals_ = obj._dbvals_ = obj._session_cache_ = None
cache.perm_cache = cache.user_roles_cache = cache.obj_labels_cache = None
else:
for obj in cache.objects:
obj._dbvals_ = obj._session_cache_ = None
for attr, setdata in iteritems(obj._vals_):
if attr.is_collection:
if not setdata.is_fully_loaded: obj._vals_[attr] = None
if db_session and db_session.strict:
for obj in cache.objects:
obj._vals_ = obj._dbvals_ = obj._session_cache_ = None
cache.perm_cache = cache.user_roles_cache = cache.obj_labels_cache = None
else:
for obj in cache.objects:
obj._dbvals_ = obj._session_cache_ = None
for attr, setdata in iteritems(obj._vals_):
if attr.is_collection:
if not setdata.is_fully_loaded: obj._vals_[attr] = None

cache.objects = cache.objects_to_save = cache.saved_objects = cache.query_results \
= cache.indexes = cache.seeds = cache.for_update = cache.max_id_cache \
Expand Down

0 comments on commit aa16b4f

Please sign in to comment.