Skip to content

Commit 36228f6

Browse files
author
Matt Howard
committed
fix(postgres): rewrite update pick list patch to avoid UPDATE JOIN
1 parent 0c30259 commit 36228f6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

erpnext/patches/v15_0/update_pick_list_fields.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,25 @@ def execute():
88

99

1010
def update_delivery_note():
11-
DN = frappe.qb.DocType("Delivery Note")
12-
DNI = frappe.qb.DocType("Delivery Note Item")
11+
# Postgres doesn't support UPDATE ... JOIN. Use UPDATE ... FROM instead.
12+
frappe.db.multisql(
13+
{
14+
"mariadb": """
15+
UPDATE `tabDelivery Note Item` dni
16+
JOIN `tabDelivery Note` dn ON dn.`name` = dni.`parent`
17+
SET dni.`against_pick_list` = dn.`pick_list`
18+
WHERE COALESCE(dn.`pick_list`, '') <> ''
19+
""",
20+
"postgres": """
21+
UPDATE "tabDelivery Note Item" dni
22+
SET against_pick_list = dn.pick_list
23+
FROM "tabDelivery Note" dn
24+
WHERE dn.name = dni.parent
25+
AND COALESCE(dn.pick_list, '') <> ''
26+
""",
27+
}
28+
)
1329

14-
frappe.qb.update(DNI).join(DN).on(DN.name == DNI.parent).set(DNI.against_pick_list, DN.pick_list).where(
15-
IfNull(DN.pick_list, "") != ""
16-
).run()
1730

1831

1932
def update_pick_list_items():

0 commit comments

Comments
 (0)