Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-1032

Realm does not support properties of this type (not Date related)

      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:

      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?

      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

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: