fix(doctype): MySQL syntax for unique fields validation

This commit is contained in:
Gavin D'souza 2020-09-15 15:07:16 +05:30
parent e4022f7f03
commit 0baec957be

View file

@ -762,7 +762,7 @@ def validate_fields(meta):
if not d.get("__islocal") and frappe.db.has_column(d.parent, d.fieldname):
has_non_unique_values = frappe.db.sql("""select `{fieldname}`, count(*)
from `tab{doctype}` where ifnull({fieldname}, '') != ''
from `tab{doctype}` where ifnull(`{fieldname}`, '') != ''
group by `{fieldname}` having count(*) > 1 limit 1""".format(
doctype=d.parent, fieldname=d.fieldname))