Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
i'm afraid this is not that trivial with nullable fields in the database.
right now, Room always finds 1 constructor. For this to work, we'll need to find all constructors, check which fields are null in the cursor and call the right constructor.
otherwise, calling the default one might result in Room passing null values into it when they are non-null.
right now, Room always finds 1 constructor. For this to work, we'll need to find all constructors, check which fields are null in the cursor and call the right constructor.
otherwise, calling the default one might result in Room passing null values into it when they are non-null.
za...@gmail.com <za...@gmail.com> #4
Ahh, I didn't know room used `@JvmOverloads` constructors. Neat!
za...@gmail.com <za...@gmail.com> #5
Mentioned in the original issue, but dropping here too.
It seems you can't have nullable val properties. If I have a class with all val properties, it works fine. It complains about multiple constructors, but it doesn't fail at least
It seems you can't have nullable val properties. If I have a class with all val properties, it works fine. It complains about multiple constructors, but it doesn't fail at least
Description
Version used: 1.1.0-present
Theme used: NA
Devices/Android versions reproduced on: NA build-time
- Relevant code to trigger the issue: Any kotlin data class in an external module. Building the following project can reproduce it:
In Kotlin, data classes will have a primary constructor and sometimes generated synthetic constructors. ROOM's processor will complain about the presence of the synthetic ones (which are usually visible when reading the class file from an external library), but since it's reading metadata it could use it to find the "primary" constructor to know for sure.
Example:
The solution would be to find that constructor, then match it to the corresponding constructor as seen in the elements API