Spine icon indicating copy to clipboard operation
Spine copied to clipboard

Dirty checking

Open wvteijlingen opened this issue 9 years ago • 12 comments

Only save dirty variables to avoid overriding in case of sparse fieldsets.

wvteijlingen avatar Apr 09 '15 10:04 wvteijlingen

https://github.com/wvteijlingen/Spine/tree/dirty-checking

wvteijlingen avatar May 27 '16 12:05 wvteijlingen

@wvteijlingen what still needs to be completed of this feature?

markst avatar Aug 24 '16 12:08 markst

I think it was pretty much done, just needs some more tests perhaps.

wvteijlingen avatar Aug 26 '16 14:08 wvteijlingen

@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

OliverDobner-flinc avatar Oct 06 '16 15:10 OliverDobner-flinc

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.

wvteijlingen avatar Oct 06 '16 15:10 wvteijlingen

The attributes were filled (at least the ones that were prefilled from backend)

OliverDobner-flinc avatar Oct 06 '16 16:10 OliverDobner-flinc

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!

wvteijlingen avatar Oct 07 '16 10:10 wvteijlingen

I will have a look, especially at not firing the request if resource is not dirty.

OliverDobner-flinc avatar Oct 07 '16 10:10 OliverDobner-flinc

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

OliverDobner-flinc avatar Oct 07 '16 12:10 OliverDobner-flinc

@wvteijlingen I opened a pull request: https://github.com/wvteijlingen/Spine/pull/116

OliverDobner-flinc avatar Oct 07 '16 13:10 OliverDobner-flinc

@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.

OliverDobner-flinc avatar Oct 07 '16 16:10 OliverDobner-flinc

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.

OliverDobner-flinc avatar Oct 07 '16 17:10 OliverDobner-flinc