Skip to content
New issue

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

RealmChangeListener not triggered, after object was deleted and replaced with same primary key. #7098

Closed
dan-ahlquist opened this issue Sep 14, 2020 · 1 comment · Fixed by #7241

Comments

@dan-ahlquist
Copy link

dan-ahlquist commented Sep 14, 2020

Goal

Receive updates through a RealmChangeListener, when a managed object is deleted, then replaced in one transaction. The new object has the same key, but other fields are updated.

Actual Results

  • For a RealmObject type with no Primary Key, the listener was triggered. (Pass)
  • For a RealmObject type with an int Primary Key, the listener was triggered. (Pass)
  • For a RealmObject type with a String Primary Key, the listener was not triggered. (Fail)

Steps & Code to Reproduce

See attached Android Studio project, which demonstrates the behavior.

  1. Pre-condition: two records in Realm (one with no PK, one with a String PK).
  2. Register a RealmChangeListener for each type.
  3. Replace each object (in separate transactions) - this is done on an RxAndroid chain.
    a. This is done by using deleteAllFromRealm, then inserting the new object
    with copyToRealm.
    b. The key of the new object is the same as the deleted one, but other
    fields are updated.

Version of Realm and tooling

Realm version(s): 7.0.0 and up.
I bisected through Realm versions. 6.1.0 was "good" and 7.0.0 was "bad"

Realm Sync feature enabled: No

Android Studio version: 4.0

Android Build Tools version: 30.0.1, and 29.0.3. Same results.

Gradle version: 3.4.0 and 4.0.0. Same results.

Which Android version and device(s): Android 9 and 10, various devices. Originally reported on S10+ with Android 9.

ChangeListenerBug.zip

@clementetb
Copy link
Collaborator

Thanks for reporting the issue and sharing the project to reproduce it. We have reported it to the realm core team who will look for a fix.

#4010

@clementetb clementetb linked a pull request Jan 8, 2021 that will close this issue
3 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants