Polishing.

See #1460
Original pull request #1521
This commit is contained in:
Jens Schauder
2023-06-13 15:48:27 +02:00
parent 06943211b7
commit 20e468021e
2 changed files with 10 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ import org.springframework.transaction.annotation.Transactional;
* @author Milan Milanov
* @author Mikhail Polivakha
* @author Chirag Tailor
* @author Vincent Galloy
*/
@ContextConfiguration
@Transactional
@@ -1046,11 +1047,13 @@ class JdbcAggregateTemplateIntegrationTests {
}
@Test // GH-1460
@EnabledOnFeature(SUPPORTS_ARRAYS)
void readEnumArray() {
EnumArrayOwner entity = new EnumArrayOwner();
entity.digits = new Color[]{Color.BLUE};
assertThat(template.save(entity)).isNotNull();
template.save(entity);
assertThat(template.findById(entity.id, EnumArrayOwner.class).digits).isEqualTo(new Color[]{Color.BLUE});
}

View File

@@ -54,6 +54,7 @@ import org.springframework.util.ClassUtils;
* @author Mark Paluch
* @author Jens Schauder
* @author Chirag Tailor
* @author Vincent Galloy
* @see MappingContext
* @see SimpleTypeHolder
* @see CustomConversions
@@ -175,7 +176,11 @@ 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() && !value.getClass().getComponentType().isEnum() && (TypeInformation.OBJECT.equals(type) || type.isCollectionLike())) {
if (value.getClass().isArray() //
&& !value.getClass().getComponentType().isEnum() //
&& (TypeInformation.OBJECT.equals(type) //
|| type.isCollectionLike()) //
) {
return value;
}