Test all the SQL constraints name first before testing common column names
Closes #13586
This commit is contained in:
1 parent
aafa890c5c
commit
abb51c5cb3
1 file changed
+7
-5
@@ -595,11 +595,13 @@ class ModelSQL(ModelStorage):
|
||||
gettext('ir.msg_required_validation',
|
||||
**cls.__names__(field_name)))
|
||||
for name, constraint, error in cls._sql_constraints:
|
||||
if (backend.TableHandler.convert_name(name) in str(exception)
|
||||
or (isinstance(constraint, (Unique, Exclude))
|
||||
and all(
|
||||
c.name in str(exception)
|
||||
for c in constraint.columns))):
|
||||
if backend.TableHandler.convert_name(name) in str(exception):
|
||||
raise SQLConstraintError(gettext(error))
|
||||
for _, constraint, error in cls._sql_constraints:
|
||||
if (isinstance(constraint, (Unique, Exclude))
|
||||
and all(
|
||||
c.name in str(exception)
|
||||
for c in constraint.columns)):
|
||||
raise SQLConstraintError(gettext(error))
|
||||
|
||||
# Check foreign key in last because this can raise false positive
|
||||
|
||||
Reference in new issue
Block a user