Merge branch '7.0.x'

This commit is contained in:
Sam Brannen
2026-09-05 14:52:07 +02:00
2 changed files with 15 additions and 1 deletions
@@ -123,7 +123,7 @@ public class SQLErrorCodes {
}
public void setDuplicateKeyCodes(String... duplicateKeyCodes) {
this.duplicateKeyCodes = duplicateKeyCodes;
this.duplicateKeyCodes = StringUtils.sortStringArray(duplicateKeyCodes);
}
public void setDataIntegrityViolationCodes(String... dataIntegrityViolationCodes) {
@@ -107,6 +107,20 @@ class SQLErrorCodeSQLExceptionTranslatorTests {
.hasCause(sqlException);
}
@Test // gh-37235
void duplicateKeyCodesDeclaredInUnsortedOrder() {
SQLErrorCodes errorCodes = new SQLErrorCodes();
errorCodes.setDuplicateKeyCodes("90002", "1586", "1062");
SQLErrorCodeSQLExceptionTranslator unsortedCodesTranslator = new SQLErrorCodeSQLExceptionTranslator(errorCodes);
for (int errorCode : new int[] {90002, 1586, 1062}) {
SQLException sqlException = new SQLException("", "", errorCode);
assertThat(unsortedCodesTranslator.translate("task", "SQL", sqlException))
.isInstanceOf(DuplicateKeyException.class)
.hasCause(sqlException);
}
}
@Test
void batchExceptionTranslation() {
SQLException badSqlEx = new SQLException("", "", 1);