realm-kotlin
realm-kotlin copied to clipboard
RealmSet contains fails with unmanaged object
Invoking RealmSet<RealmObject>.contains on a managed set passing an unmanaged Realm value would result in the following exception:
IllegalStateException: Cannot modify managed objects outside of a write transaction
The exception is a bit odd, how come we modify objects during the contains?
@Test
fun containsFailWith() {
val unmanaged = RealmSetContainer()
val managed = realm.writeBlocking {
copyToRealm(
RealmSetContainer().apply {
objectSetField.add(RealmSetContainer())
}
)
}
managed.objectSetField.contains(unmanaged)
}
This is fixed in https://github.com/realm/realm-kotlin/tree/next-major as part of the Collections in mixed-implmentation. Previous issue was https://github.com/realm/realm-kotlin/issues/1488. It required quite some changes throughout the operator-infrastructure so don't think it is worth fixing in isolation.
Fixed by #1716