Closed
Description
We are seeing strange behavior that is different that that of the JS 1.5 and lower SDK in that when we update a field on an object that has included objects (fully hydrated), we see that the included objects decay to pointers after performing the update. We want to add this to the list of things we've discovered as blockers in #73.
This is a reproduction using the Parse JS SDK 1.6.9:
Setup
class Brand extends Parse.Object {
constructor(attributes, options) {
super('Brand', attributes, options);
}
}
Parse.Object.registerSubclass('Brand', Brand);
class Item extends Parse.Object {
constructor(attributes, options) {
super('Item', attributes, options);
}
}
Parse.Object.registerSubclass('Item', Item);
Test
var freshItem = new Item({cool: true});
var freshBrand = new Brand({item: item});
Parse.Object.saveAll([freshItem, freshBrand]).then((brand, item) => {
var query = new Parse.Query(Brand);
query.include('item');
return query.get(brand.id);
}).then((savedBrand) => {
var item = savedBrand.get('item');
assert(item.has("cool")); // has attributes of item (not decayed)
assert(item.get("cool")); // has attributes of item (not decayed)
// This update will cause included objects on savedBrand to decay.
brand.set('newField', true);
return brand.save().then((updatedBrand) => {
var item = savedBrand.get('item');
assert(item.has("cool")); // fails, no attributes of item present (decayed)
assert(item.get("cool")); // fails, no attributes of item present (decayed)
});
})
When we attempt the same actions in the 1.5 SDK and lower the pointers do not decay (run line by line in our node REPL)
var Item = Parse.Object.extend("Item")
var Brand = Parse.Object.extend("Brand")
var brand = new Brand({name: "Acme"})
var item = new Item({brand: brand})
item.save()
var itemRef;
var itemQuery = new Parse.Query(Item);
itemQuery.include("brand").get("n0EnLswyJv").then(function(fetchedItem) {
itemRef = fetchedItem;
})
itemRef.get("brand").get("name")
> 'Acme'
itemRef.set("price", 30)
itemRef.save()
itemRef.get("brand").get("name")
> 'Acme'
Metadata
Metadata
Assignees
Labels
No labels