We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always
I have a KMP app that is getting a "Realm does not support properties of this type" when I try to execute it.
Here is the code:
class Patient() : RealmObject { @PrimaryKey var _id: ObjectId = ObjectId() var firstName: String = "" var lastName: String = "" var visits: Array<PelletInsertionVisit> = arrayOf(PelletInsertionVisit()) <---- ERROR on this line constructor(first: String = "", last: String = "") : this() { firstName = first lastName = last } } class PelletInsertionVisit() : RealmObject { @PrimaryKey var _id: ObjectId = ObjectId() var visitDate = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) //Note this is a Long, not a Date var pelletsUsed: Array<Pellet> = arrayOf(Pellet()) constructor(pelletArray: Array<Pellet>, date: Long) : this() { visitDate = date pelletsUsed = pelletArray } } class Pellet(): RealmObject { @PrimaryKey var _id: ObjectId = ObjectId() var size = PelletSize.ZERO.value var lotNumber: String = "UNKNOWN" constructor(pelletSize: Int, lot: String = "") : this() { size = pelletSize lotNumber = lot } } enum class PelletSize (val value: Int){ ZERO(0), //UNSET TEN(10), TWENTY_FIVE(25), FIFTY(50), ONE_HUNDRED(100), TWO_HUNDRED(200); companion object { private val types = entries.associateBy { it.value } fun findByValue(value: Int): PelletSize? = types[value] } }
I thought as long as the variables within the class were supported, it was OK to create arrays of class objects. What am I doing wrong here, please?
No response
1.11.0
Local Database only
No
Kotlin 1.9.22 Android 34
Android Studio version: 2023.2.1 Android Build Tools version: 35-rc1 Gradle version: 8.4
The text was updated successfully, but these errors were encountered:
➤ PM Bot commented:
Jira ticket: RKOTLIN-1032
Sorry, something went wrong.
According to the docs, collections in Kotlin are represented using RealmList rather than an array. Can you try replacing the array declaration with:
RealmList
var visits: RealmList<PelletInsertionVisit> = realmListOf()
BINGO! Thanks for solving and apologies for not seeing this in the documentation.
Closing.
No branches or pull requests
How frequently does the bug occur?
Always
Description
I have a KMP app that is getting a "Realm does not support properties of this type" when I try to execute it.
Here is the code:
I thought as long as the variables within the class were supported, it was OK to create arrays of class objects. What am I doing wrong here, please?
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
No response
Version
1.11.0
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Kotlin 1.9.22 Android 34
Build environment
Android Studio version: 2023.2.1
Android Build Tools version: 35-rc1
Gradle version: 8.4
The text was updated successfully, but these errors were encountered: