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

Imports through `RealmAny` does check for duplicate object reference inside the imported tree

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      Importing objects through a RealmAny field does not check for duplicate references to the same object, thus the following test will fail as the child is imported multiple times:

      @Test
      fun importWithDuplicateReference() = runBlocking {
          realm.write {
              val child = Sample().apply { stringField = "CHILD" }
              val parent = Sample().apply {
                  nullableRealmAnyField = RealmAny.create(child)
                  nullableRealmAnyListField = realmListOf(RealmAny.create(child))
              }
              copyToRealm(parent)
          }
          assertEquals(1, realm.query<Sample>("stringField = 'CHILD'").find().size)
      }
      

            Assignee:
            claus.rorbech@mongodb.com Claus Rørbech (Inactive)
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: