Compare integrity error message with the constraint name prefixed by the table name

The TableHandler adds the table name as prefix to the constraint name so when
comparing with the integrity error message, it should also be added.
Especially if the constraint name is hashed by the TableHandler conversion
because the result is completely different.

Closes #13922
(grafted from 57e97b6d957e1b472eea3fb7bbdf2ecf03abfc6a)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2025-03-15 13:31:57 +01:00
1 parent 896ccf9075
commit 84c7b3a416
1 file changed
+1
+1
View File
@@ -359,6 +359,7 @@ class ModelSQL(ModelStorage):
gettext('ir.msg_required_validation_record',
**cls.__names__(field_name)))
for name, _, error in cls._sql_constraints:
name = cls._table + '_' + name
if backend.TableHandler.convert_name(name) in str(exception):
raise SQLConstraintError(gettext(error))
# Check foreign key in last because this can raise false positive