fix: commit regardless of framework's transaction_writes count (#25322)

- 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.
This commit is contained in:
Ankush Menat 2024-03-11 15:18:38 +05:30 committed by GitHub
parent b56e94d1af
commit acf398f46e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: