fix(sqlite): use correct check for unique/primary key constraint violations
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
05fca5b16b
commit
9fa330c075
2 changed files with 5 additions and 5 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue