Skip to content

Commit

Permalink
fix: commit regardless of framework's transaction_writes count (#25322)…
Browse files Browse the repository at this point in the history
… (#25328)

- There is code that depends on "commit", everything that happens with `db.after_commit`.
- There are operations that will not write anything to DB but just
  enqueue the function, if it's enqueue_after_commit then it will break.

(cherry picked from commit acf398f)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Mar 11, 2024
1 parent 74a1a8d commit c7c726e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions frappe/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,7 @@ def handle_exception(e):

def sync_database(rollback: bool) -> bool:
# if HTTP method would change server state, commit if necessary
if (
frappe.db
and (frappe.local.flags.commit or frappe.local.request.method in UNSAFE_HTTP_METHODS)
and frappe.db.transaction_writes
):
if frappe.db and (frappe.local.flags.commit or frappe.local.request.method in UNSAFE_HTTP_METHODS):
frappe.db.commit()
rollback = False
elif frappe.db:
Expand Down

0 comments on commit c7c726e

Please sign in to comment.