spring-data-commons icon indicating copy to clipboard operation
spring-data-commons copied to clipboard

KPropertyPath doesn't support Iterables

Open ghost opened this issue 2 years ago • 1 comments

The KPropertyPath currently doesn't support references from Iterables such as List, Set, etc. to the type of the element.

data class User(
    val name: String,
    val addresses: List<Address>
) {
    data class Address(
        val street: String
    )
}

val path = User::addresses / User.Address::street // a type mismatch between the expected the `Address` and offered `List<Address>` occurs here

The implementation in org.springframework.data.mapping.KPropertyPath should be able to construct paths such as addresses.street for the usage in indexes, queries and aggregations to leverage the type-safety of Kotlin for paths references in Spring Data MongoDB.

A similar implementation is offered by the now deprecated project KMongo, see KPropertyPath.kt and Properties.kt.

ghost avatar Dec 21 '23 12:12 ghost

Care to submit a pull request?

mp911de avatar Dec 27 '23 07:12 mp911de