fix(model): fix postgres compatibility in update_user_settings

In Postgres, double quotes denote identifiers. The previous LIKE clause format caused "UndefinedColumn" errors during field renaming (e.g., during HRMS installation) because the pattern was interpreted as a column name.

This change parameterizes the LIKE pattern and passes the wildcarded value as a bound parameter, ensuring compatibility with both MySQL and Postgres.
This commit is contained in:
Tai Cai 2025-12-24 11:33:42 +07:00
parent 5df262350f
commit 12efd72cc9

View file

@ -166,9 +166,9 @@ def update_user_settings(doctype, old_fieldname, new_fieldname):
sync_user_settings()
user_settings = frappe.db.sql(
''' select user, doctype, data from `__UserSettings`
where doctype=%s and data like "%%%s%%"''',
(doctype, old_fieldname),
""" select user, doctype, data from `__UserSettings`
where doctype=%s and data like %s""",
(doctype, f"%{old_fieldname}%"),
as_dict=1,
)