realm-js
realm-js copied to clipboard
Incorrect Results Delete Change Notifications
Goals
- Provision of correct fine grained change notifications for Results instances upon deletes.
- Expected Results
- I expected that upon removing the first instance from a Results instance like this
const firstObjectOfType = realm.objects('Dog')[0];
realm.write(() => {
realm.delete(firstObjectOfType);
});
- I would get this for changes notifications:
{
insertions: [],
deletions: [0],
modifications: []
}
Actual Results
- Instead I got this for changes notifications
{
insertions: [0],
deletions: [0, <index of last element(i.e. if length 3 then index 2)>],
modifications: []
}
- This is occurring for Results whose length is greater than 2 for whatever reason.
- So it only works for a Results set of lengths 1 and 2.
Steps to Reproduce
- With provided code sample or one of your own do the following:
- Add at least 3 objects of a type(i.e. click the Add Rex button 3 times)
- Remove the first resource(i.e. click the Remove First button 1 time)
- Code Sample
- Gist of Root Component to Register with React Native
Version of Realm and Tooling
- Realm JS SDK Version: 2.0.12
- Node: 8.6.0
- React Native: 0.50.4
- Client OS & Version: 10.12.6
- Which debugger for React Native: Chrome Remote Debugger
@509dave16 Sorry for the late reply. I imagine that you are seeing something similar to https://github.com/realm/realm-object-store/issues/373.
@kneth No problem. That issue you referenced is indeed an instance of the same problem. Understand that there's varying priorities and progress being made on them. Really appreciate the response. Let me know if you need anything else from me regarding this issue.
@509dave16 If you have time, I would appreciate if you can turn your Gist into a unit test.
@kneth Sure. I'll try my hand at making a few unit tests to cover the good/bad cases.
@kneth Was spending some time today getting to the point of writing the unit tests, but I can't even get the test runners to pass. I have created a gist with my output. If there is a particular installation process I should follow(i.e. yarn) or a particular environment setup (ie Node v6,v7,v8, etc...) let me know. Thanks! yarn and yarn run test-runners output
It looks like you didn't do git submodule update --init --recursive
to pull in our dependencies (e.g., Realm Object Store).