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 @@ -27,7 +27,7 @@ import kotlin.reflect.KProperty1
27
27
* @since 2.2
28
28
*/
29
29
class KPropertyPath <T , U >(
30
- internal val parent : KProperty <U >,
30
+ internal val parent : KProperty <U ? >,
31
31
internal val child : KProperty1 <U , T >
32
32
) : KProperty<T> by child
33
33
@@ -52,7 +52,8 @@ internal fun asString(property: KProperty<*>): String {
52
52
* Book::author / Author::name isEqualTo "Herman Melville"
53
53
* ```
54
54
* @author Tjeu Kayim
55
+ * @author Yoann de Martino
55
56
* @since 2.2
56
57
*/
57
- operator fun <T , U > KProperty<T>.div (other : KProperty1 <T , U >) =
58
+ operator fun <T , U > KProperty<T? >.div (other : KProperty1 <T , U >) =
58
59
KPropertyPath (this , other)
Original file line number Diff line number Diff line change @@ -93,6 +93,15 @@ class KPropertyPathTests {
93
93
assertThat(property).isEqualTo(" entity.book.author.name" )
94
94
}
95
95
96
+ @Test
97
+ fun `Convert nullable KProperty to field name` () {
98
+ class Cat (val name : String )
99
+ class Owner (val cat : Cat ? )
100
+
101
+ val property = asString(Owner ::cat / Cat ::name)
102
+ assertThat(property).isEqualTo(" cat.name" )
103
+ }
104
+
96
105
class Book (val title : String , val author : Author )
97
106
class Author (val name : String )
98
107
}
You can’t perform that action at this time.
0 commit comments