Fix Enum[] type conversion.
Since 3.0.5, Enum[] type are detect as "UNKNOWN" Closes #1460 Original Pull request #1521
This commit is contained in:
committed by
Jens Schauder
parent
b07abd7afc
commit
fb97bfca97
@@ -1082,6 +1082,16 @@ class JdbcAggregateTemplateIntegrationTests {
|
||||
assertThat(template.findById(entity.id, WithInsertOnly.class).insertOnly).isEqualTo("first value");
|
||||
}
|
||||
|
||||
@Test // GH-1460
|
||||
void readEnumArray() {
|
||||
EnumArrayOwner entity = new EnumArrayOwner();
|
||||
entity.digits = new Color[]{Color.BLUE};
|
||||
|
||||
assertThat(template.save(entity)).isNotNull();
|
||||
|
||||
assertThat(template.findById(entity.id, EnumArrayOwner.class).digits).isEqualTo(new Color[]{Color.BLUE});
|
||||
}
|
||||
|
||||
private <T extends Number> void saveAndUpdateAggregateWithVersion(VersionedAggregate aggregate,
|
||||
Function<Number, T> toConcreteNumber) {
|
||||
saveAndUpdateAggregateWithVersion(aggregate, toConcreteNumber, 0);
|
||||
@@ -1123,6 +1133,17 @@ class JdbcAggregateTemplateIntegrationTests {
|
||||
return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM " + tableName, emptyMap(), Long.class);
|
||||
}
|
||||
|
||||
enum Color {
|
||||
BLUE
|
||||
}
|
||||
|
||||
@Table("ARRAY_OWNER")
|
||||
private static class EnumArrayOwner {
|
||||
@Id Long id;
|
||||
|
||||
Color[] digits;
|
||||
}
|
||||
|
||||
@Table("ARRAY_OWNER")
|
||||
private static class ArrayOwner {
|
||||
@Id Long id;
|
||||
|
||||
@@ -176,7 +176,7 @@ public class BasicRelationalConverter implements RelationalConverter {
|
||||
|
||||
// TODO: We should add conversion support for arrays, however,
|
||||
// these should consider multi-dimensional arrays as well.
|
||||
if (value.getClass().isArray() && (TypeInformation.OBJECT.equals(type) || type.isCollectionLike())) {
|
||||
if (value.getClass().isArray() && !value.getClass().getComponentType().isEnum() && (TypeInformation.OBJECT.equals(type) || type.isCollectionLike())) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user