File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/kotlin/org/springframework/data/mongodb/core/query
test/kotlin/org/springframework/data/mongodb/core/query Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import kotlin.reflect.KProperty1
2525 * @since 2.2
2626 */
2727class KPropertyPath <T , U >(
28- internal val parent : KProperty <U >,
28+ internal val parent : KProperty <U ? >,
2929 internal val child : KProperty1 <U , T >
3030) : KProperty<T> by child
3131
@@ -50,7 +50,8 @@ internal fun asString(property: KProperty<*>): String {
5050 * Book::author / Author::name isEqualTo "Herman Melville"
5151 * ```
5252 * @author Tjeu Kayim
53+ * @author Yoann de Martino
5354 * @since 2.2
5455 */
55- operator fun <T , U > KProperty<T>.div (other : KProperty1 <T , U >) =
56+ operator fun <T , U > KProperty<T? >.div (other : KProperty1 <T , U >) =
5657 KPropertyPath (this , other)
Original file line number Diff line number Diff line change @@ -60,6 +60,15 @@ class KPropertyPathTests {
6060 assertThat(property).isEqualTo(" entity.book.author.name" )
6161 }
6262
63+ @Test
64+ fun `Convert nullable KProperty to field name` () {
65+ class Cat (val name : String )
66+ class Owner (val cat : Cat ? )
67+
68+ val property = asString(Owner ::cat / Cat ::name)
69+ assertThat(property).isEqualTo(" cat.name" )
70+ }
71+
6372 class Book (val title : String , val author : Author )
6473 class Author (val name : String )
6574}
You can’t perform that action at this time.
0 commit comments