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
25
25
* @since 2.2
26
26
*/
27
27
class KPropertyPath <T , U >(
28
- internal val parent : KProperty <U >,
28
+ internal val parent : KProperty <U ? >,
29
29
internal val child : KProperty1 <U , T >
30
30
) : KProperty<T> by child
31
31
@@ -50,7 +50,8 @@ internal fun asString(property: KProperty<*>): String {
50
50
* Book::author / Author::name isEqualTo "Herman Melville"
51
51
* ```
52
52
* @author Tjeu Kayim
53
+ * @author Yoann de Martino
53
54
* @since 2.2
54
55
*/
55
- operator fun <T , U > KProperty<T>.div (other : KProperty1 <T , U >) =
56
+ operator fun <T , U > KProperty<T? >.div (other : KProperty1 <T , U >) =
56
57
KPropertyPath (this , other)
Original file line number Diff line number Diff line change @@ -60,6 +60,15 @@ class KPropertyPathTests {
60
60
assertThat(property).isEqualTo(" entity.book.author.name" )
61
61
}
62
62
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
+
63
72
class Book (val title : String , val author : Author )
64
73
class Author (val name : String )
65
74
}
You can’t perform that action at this time.
0 commit comments