parse-community/Parse-SDK-Android

Dirty fields persisting even after unpinning (LDB enabled).

Opened this issue · 0 comments

So I know if dirty fields exists , even if I fetch the new object from server , it won't override my existing object since the dirty changes are yet to be saved.
BUT
Let's say I have an object , I make some local changes and I only pin them. Now the object is dirty.
But after unpinning (which was successful), when I fetch and re-pin the object still has the dirty value.
How is this possible ?
So if an object has dirty values does that mean unpin really doesn't unpin ?

Lets say example object of Class A has these two fields
{ "age": 18, "name": "back4app" }
Steps to reproduce:
1 ) Query an object from the cloud and pin it normally

query.get(....
  public void done(ParseObject obj,ParseException e){
      obj.pinInBackground();
   }
}
  1. After fetching and pinning is done (from cloud) , let's change a value of the object and pin it.
query.fromLocalDatastore;
query.get(.........
  public void done(ParseObject obj,ParseException e){
      obj.put("name", "firebase");
      obj.pinInBackground();
   }
}

So now we have a dirty field "name" of the following object.`
Now let's say somewhere in the cloud the data for name field was changed to "azure"and I need the latest update. But I know since my local object has dirty fields , even if I fetch the latest object and pin it , this object's name value will still be "firebase".
Understand.
Okay now let's try unpinning.
3) Unpin the object from local DB.

ParseObject.unpinAllInBackground()

After unpin is successful let's retrieve the same object form cloud once again and pin it.

query.get(....
  public void done(ParseObject obj,ParseException e){
      obj.pinInBackground();
   }
}
  1. Let's check the name field of the object :
    obj.get("name");
    Expected result : "azure".
    Actual result : "firebase".
    UPDATE
    This only works as expected if I close the application after unpinning and re-open it and fetch new data
    But that's really inconvenient.