Spine
Spine copied to clipboard
Dirty checking
Only save dirty variables to avoid overriding in case of sparse fieldsets.
https://github.com/wvteijlingen/Spine/tree/dirty-checking
@wvteijlingen what still needs to be completed of this feature?
I think it was pretty much done, just needs some more tests perhaps.
@wvteijlingen I did a simple test, fetched an object A from backend, set a oneToOneRelationShip from nil to a new object and expected only the new object B to be created with a POST-Request on ".....ObjectA/id_1234/relationship/ObjectB as ObjectA had no change. But Spine did send a PATCH-Request to ....ObjectA
That is currently the way it is supposed to work. What was the content of that PATCH request? It should contain no attributes.
It's would be a good extra feature though to first check for dirty attributes to see if we actually need to fire the request.
The attributes were filled (at least the ones that were prefilled from backend)
Hmm, then there is something wrong. I don't have much time to work on this now, so if you could write a failing test for this that would be great!
I will have a look, especially at not firing the request if resource is not dirty.
Ok, I identified the problem ... you tested in SerializerTests and set the .DirtyFieldsOnly option in the test explicitly. When updating a resource these option is not set. I will create a pull request later
@wvteijlingen I opened a pull request: https://github.com/wvteijlingen/Spine/pull/116
@wvteijlingen Ok, I found another issue, nil-attributes were not handled properly. I did fix this and made a pull request containing a test and a check so that no request is made at all if the resource is not dirty.
Ok, Pull request https://github.com/wvteijlingen/Spine/pull/116 is updated. @wvteijlingen please take a look and merge this one, I while continue working with this branch and keep you updated.