From 8d8fa78bee65825ce5033b1d21fd67b09f12baca Mon Sep 17 00:00:00 2001 From: Aarol D'Souza <98270103+AarDG10@users.noreply.github.com> Date: Sun, 4 Jan 2026 10:18:53 +0530 Subject: [PATCH] fix(postgres): add pg compatible query for copying comm_date from comm to comm_link (#35488) --- .../copy_communication_date_to_link.py | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/frappe/core/doctype/communication_link/patches/copy_communication_date_to_link.py b/frappe/core/doctype/communication_link/patches/copy_communication_date_to_link.py index 0a6cd1ee5e..563acd8f8d 100644 --- a/frappe/core/doctype/communication_link/patches/copy_communication_date_to_link.py +++ b/frappe/core/doctype/communication_link/patches/copy_communication_date_to_link.py @@ -6,18 +6,32 @@ def execute(): batch_size = 10_000 while True: - frappe.db.sql( - """ - update `tabCommunication Link` cl - inner join `tabCommunication` c on cl.parent = c.name - set cl.communication_date = c.communication_date - where cl.communication_date is null - and c.communication_date is not null - limit %s - """, + frappe.db.multisql( + { + "mariadb": """ + update `tabCommunication Link` cl + inner join `tabCommunication` c on cl.parent = c.name + set cl.communication_date = c.communication_date + where cl.communication_date is null + and c.communication_date is not null + limit %s + """, + "postgres": """ + UPDATE "tabCommunication Link" + SET communication_date = sub.communication_date + FROM ( + SELECT cl.name, c.communication_date + FROM "tabCommunication Link" cl + JOIN "tabCommunication" c ON cl.parent = c.name + WHERE cl.communication_date IS NULL + AND c.communication_date IS NOT NULL + LIMIT %s + ) AS sub + WHERE "tabCommunication Link".name = sub.name + """, + }, (batch_size,), ) - frappe.db.commit() if not frappe.db.sql(