Skip to content

Commit

Permalink
fix db_session(sql_debug=True): it should log SQL commands also durin…
Browse files Browse the repository at this point in the history
…g db_session.__exit__()
  • Loading branch information
kozlovsky committed Nov 6, 2018
1 parent e19013d commit 29bbf4a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pony/orm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,15 @@ def _enter(db_session):
if db_session.sql_debug is not None:
local.push_debug_state(db_session.sql_debug, db_session.show_values)
def __exit__(db_session, exc_type=None, exc=None, tb=None):
if db_session.sql_debug is not None:
local.pop_debug_state()
local.db_context_counter -= 1
if local.db_context_counter: return
assert local.db_session is db_session
try:
if not local.db_context_counter:
assert local.db_session is db_session
db_session._commit_or_rollback(exc_type, exc, tb)
finally:
if db_session.sql_debug is not None:
local.pop_debug_state()
def _commit_or_rollback(db_session, exc_type, exc, tb):
try:
if exc_type is None: can_commit = True
elif not callable(db_session.allowed_exceptions):
Expand Down

0 comments on commit 29bbf4a

Please sign in to comment.