spring-projects / spring-data-relational

Spring Data Relational. Home of Spring Data JDBC and Spring Data R2DBC.
https://spring.io/projects/spring-data-jdbc
Apache License 2.0
753 stars 345 forks source link

PostgreSQL empty array column returns a null Java value instead of an empty array. #1833

Closed Jul13nT closed 1 month ago

Jul13nT commented 1 month ago

I have an Entity with a field of type String[], mapped to a PostgreSQL database with a text[] column.

With Spring Data JDBC (Spring Boot 3.3.1), when using JdbcAggregateOperations.findAll API (or others like findOne) the result entity for this field is null when the column is empty.

I'm expecting the following results:

The third case returns null instead of an empty array.

I have made a reproduction repo: https://github.com/Jul13nT/spring-data-jdbc-empty-array You can run the CustomerRepositoryTest to see the problem. The first customer has two values, the second one has null value and the third one as well (but should be empty).

Jul13nT commented 1 month ago

Oops sorry, I think this is the same case as #1826