diff --git a/frappe/database/sqlite/database.py b/frappe/database/sqlite/database.py index 2e5f98774f..00537cba35 100644 --- a/frappe/database/sqlite/database.py +++ b/frappe/database/sqlite/database.py @@ -78,12 +78,12 @@ class SQLiteExceptionUtil: return "too many columns" in str(e) @staticmethod - def is_primary_key_violation(e: sqlite3.Error) -> bool: - return "UNIQUE constraint failed" in str(e) + def is_primary_key_violation(e: sqlite3.IntegrityError) -> bool: + return e.sqlite_errorcode == 1555 @staticmethod - def is_unique_key_violation(e: sqlite3.Error) -> bool: - return "UNIQUE constraint failed" in str(e) + def is_unique_key_violation(e: sqlite3.IntegrityError) -> bool: + return e.sqlite_errorcode == 2067 @staticmethod def is_interface_error(e: sqlite3.Error): diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index 960e7cb382..bfd8c9271c 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -717,7 +717,7 @@ class BaseDocument: doc.db_update() def show_unique_validation_message(self, e): - if frappe.db.db_type != "postgres": + if frappe.db.db_type == "mariadb": fieldname = str(e).split("'")[-2] label = None