Skip to content

Mapping empty postgres text[] column sets field to null in 3.3.1 #1826

Closed
@Tree4Free

Description

@Tree4Free

As written in this comment #1737 (comment) after upgrading to spring-data-jdbc 3.3.1 when I load an entity with a text[] column (mapped as List<String>) that is empty using findById the column is set to null.

My guess is that bug was introduced by this issue #1737 but I didn't look into the changes to confirm that.


An example of my setup taken from the comment linked above:

Using a combination of Java + Kotlin:
My Entity: (Java + Lombok)

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class MyTable extends Entity {
    List<String> tags;
}

My database table (postgres):

create table my_table
(
    id uuid not null,
    version bigint not null,
    tags text[] not null,
    constraint pk_my_table primary key (id)
);

My test case (Kotlin)

@Repository
interface MyTableRepository: CrudRepository<MyTable, UUID>, PagingAndSortingRepository<MyTable, UUID>

@Test
fun test() {
    val instance = myTableRepository.save(MyTable(null, 0, emptyList())) // instance.tags is still an empty list
    assertNotNull(myTableRepository.findById(instance.id).get().tags) // data from db tags is null
}

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions