mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Merge branch '7.0.x'
This commit is contained in:
@@ -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) {
|
||||
|
||||
+14
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user