perf: Avoid ordering for link field checks (#38928)
This commit is contained in:
parent
e13017794b
commit
27712f3c76
1 changed files with 9 additions and 3 deletions
|
|
@ -138,7 +138,7 @@ def delete_doc(
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
delete_controllers(name, doc.module)
|
delete_controllers(name, doc.module)
|
||||||
except (OSError, KeyError):
|
except OSError, KeyError:
|
||||||
# in case a doctype doesnt have any controller code nor any app and module
|
# in case a doctype doesnt have any controller code nor any app and module
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -148,7 +148,7 @@ def delete_doc(
|
||||||
# Lock the doc without waiting
|
# Lock the doc without waiting
|
||||||
try:
|
try:
|
||||||
frappe.db.get_value(doctype, name, for_update=True, wait=False)
|
frappe.db.get_value(doctype, name, for_update=True, wait=False)
|
||||||
except (frappe.QueryTimeoutError, frappe.QueryDeadlockError):
|
except frappe.QueryTimeoutError, frappe.QueryDeadlockError:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"This document can not be deleted right now as it's being modified by another user. Please try again after some time."
|
"This document can not be deleted right now as it's being modified by another user. Please try again after some time."
|
||||||
|
|
@ -339,7 +339,13 @@ def get_linked_docs(doc, method="Delete") -> list[dict]:
|
||||||
if meta.istable:
|
if meta.istable:
|
||||||
fields.extend(["parent", "parenttype"])
|
fields.extend(["parent", "parenttype"])
|
||||||
|
|
||||||
for item in frappe.db.get_values(link_dt, {link_field: doc.name}, fields, as_dict=True):
|
for item in frappe.db.get_values(
|
||||||
|
link_dt,
|
||||||
|
{link_field: doc.name},
|
||||||
|
fields,
|
||||||
|
as_dict=True,
|
||||||
|
order_by=None,
|
||||||
|
):
|
||||||
# available only in child table cases
|
# available only in child table cases
|
||||||
item_parent = getattr(item, "parent", None)
|
item_parent = getattr(item, "parent", None)
|
||||||
linked_parent_doctype = item.parenttype if item_parent else link_dt
|
linked_parent_doctype = item.parenttype if item_parent else link_dt
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue