diff --git a/frappe/patches/v12_0/replace_null_values_in_tables.py b/frappe/patches/v12_0/replace_null_values_in_tables.py index e2895ed6f7..023a255a6d 100644 --- a/frappe/patches/v12_0/replace_null_values_in_tables.py +++ b/frappe/patches/v12_0/replace_null_values_in_tables.py @@ -1,4 +1,5 @@ import frappe +import re def execute(): fields = frappe.db.sql(""" @@ -14,7 +15,7 @@ def execute(): update_column_table_map[field.TABLE_NAME].append("`{fieldname}`=COALESCE(`{fieldname}`, 0)".format(fieldname=field.COLUMN_NAME)) for table in frappe.db.get_tables(): - if update_column_table_map.get(table): + if update_column_table_map.get(table) and frappe.db.exists("DocType", re.sub('^tab', '', table)): frappe.db.sql("""UPDATE `{table}` SET {columns}""" .format(table=table, columns=", ".join(update_column_table_map.get(table))))