Skip to content

Problem updating array stored on local-datastore #127

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

Closed
artemidius opened this issue Sep 11, 2015 · 5 comments
Closed

Problem updating array stored on local-datastore #127

artemidius opened this issue Sep 11, 2015 · 5 comments

Comments

@artemidius
Copy link

Please Help!

On every launch my app loads fresh data from parse.com and pins all objects to use app without network requests.

code:

public void pinKids() {
ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_KIDS);
    query.whereEqualTo(ParseConstants.KEY_PARENT, currentUser);
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(final List<ParseObject> kidsList, ParseException e) {
            if (e == null) {

                ParseObject.unpinAllInBackground(ParseConstants.LABEL_KIDS, new DeleteCallback() {
                    @Override
                    public void done(ParseException e) {
                        ParseObject.pinAllInBackground(ParseConstants.LABEL_KIDS, kidsList, new SaveCallback() {
                            @Override
                            public void done(ParseException e) {

                                Log.d("Hello", "pinKids");

                            }
                        });

                    }
                });

            }
        }
    });
}

One of the columns in my class is an array of strings (it stores history messages). I found that my code doesn't refresh this array if that array was updated from the other device (the same user did something on the other device). The rest of the data (other columns) refresh without problems. But the array of strings stays as it was downloaded at first launch.

In parse.com dashboard I see that array is updated. But code doesn't download this array while all the other columns are downloaded correctly.

Let me say that when I update this array on device-1 the new data is stored on device-1 and on "parse.com" too. But it doesn't update on device-2.

For example if you add item1 fom device-1. Array in parse-cloud contains
[ "item1" ]
If then you update array on device-2 with item2 and item3, Parse-array will contain
[ "item2" ,"item3" ]
And if then you'll use device-1 to add item4. Parse-cloud will contain
["item1", "item4" ]

I see that after query objects contain fresh data downloaded from parse-cloud. But array contains only old data that was pinned at first launch and updated locally. It means that query excludes array.

And all other columns (not arrays) update correctly.

For me it looks pretty like Bug.

I've already tried
http://stackoverflow.com/questions/32434968/android-parse-com-array-is-not-updating

and google groups
https://groups.google.com/forum/#!topic/parse-developers/YCUhpOfJees

With no result

@grantland
Copy link
Contributor

This actually sounds like a side-affect of Mutable Containers, which tries to keep track of changes containers such as JSONArray. If you're using getJSONArray(key) for your array of strings, ParseObject will store a copy of the array as a JSONArray as a dirty change and any call to get thereafter will return the dirty version regardless if the server data is updated. We're actually proposing removing this feature to clear up confusion that it causes such as this issue you've encountered and it'd be great to hear your voice on #58.

The best workaround for now would be to replace all calls to getJSONArray(key) with getList(key). You might also need revert()/revert(key) from #111 to clear out dirty changes you've made on existing installations of your application.

@grantland grantland self-assigned this Sep 11, 2015
@artemidius
Copy link
Author

Dear grantland, your solution works well. Let those coding gods bless you !!!
So how can I raise my voise for #111? I would like to.

@grantland
Copy link
Contributor

Just a comment on the issue on whether or not you are ok with the proposed change would be enough!

@grantland
Copy link
Contributor

@artemidius Sorry, but the issue was actually #58, not #111. I've updated my original comment.

@grantland
Copy link
Contributor

Fixed by #108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants