diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 7d619ac8b0..b3842a0a77 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -273,7 +273,7 @@ def validate_fields(meta): frappe.throw(_("Precision should be between 1 and 6")) def check_unique_and_text(d): - if d.unique and d.fieldtype in ("Text", "Long Text", "Small Text", "Code", "Text Editor"): + if getattr(d, "unique", False) and d.fieldtype in ("Text", "Long Text", "Small Text", "Code", "Text Editor"): frappe.throw(_("Fieldtype {0} for {1} cannot be unique").format(d.fieldtype, d.label)) if d.search_index and d.fieldtype in ("Text", "Long Text", "Small Text", "Code", "Text Editor"): diff --git a/frappe/model/db_schema.py b/frappe/model/db_schema.py index 3cf09fb7e3..3931c38cd1 100644 --- a/frappe/model/db_schema.py +++ b/frappe/model/db_schema.py @@ -259,7 +259,7 @@ class DbColumn: and not self.default.startswith(":") and column_def not in ('text', 'longtext'): column_def += ' default "' + self.default.replace('"', '\"') + '"' - if self.unique and column_def not in ('text', 'longtext'): + if self.unique and (column_def not in ('text', 'longtext')): column_def += ' unique' return column_def