File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
main/java/org/springframework/jdbc/support
test/java/org/springframework/jdbc/support Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -523,8 +523,9 @@ public static String convertPropertyNameToUnderscoreName(@Nullable String name)
523
523
char c = name .charAt (i );
524
524
if (Character .isUpperCase (c )) {
525
525
result .append ('_' ).append (Character .toLowerCase (c ));
526
- }
527
- else {
526
+ } else if (Character .isDigit (c ) && !Character .isDigit (name .charAt (i - 1 ))) {
527
+ result .append ('_' ).append (c );
528
+ } else {
528
529
result .append (c );
529
530
}
530
531
}
Original file line number Diff line number Diff line change @@ -58,4 +58,11 @@ void convertUnderscoreNameToPropertyName() {
58
58
assertThat (JdbcUtils .convertUnderscoreNameToPropertyName ("some_name_with_1_digit" )).isEqualTo ("someNameWith1Digit" );
59
59
}
60
60
61
+ @ Test
62
+ void convertPropertyNameToUnderscoreName () {
63
+ assertThat (JdbcUtils .convertPropertyNameToUnderscoreName ("AName" )).isEqualTo ("a_name" );
64
+ assertThat (JdbcUtils .convertPropertyNameToUnderscoreName ("someoneElsesName" )).isEqualTo ("someone_elses_name" );
65
+ assertThat (JdbcUtils .convertPropertyNameToUnderscoreName ("someNameWith1Digit" )).isEqualTo ("some_name_with_1_digit" );
66
+ assertThat (JdbcUtils .convertPropertyNameToUnderscoreName ("someNameWith12Number" )).isEqualTo ("some_name_with_12_number" );
67
+ }
61
68
}
You can’t perform that action at this time.
0 commit comments