django-oscar/django-oscar-api

When doing a patch operation on admin/product, images are inserted rather than updated.

benmehlman opened this issue · 4 comments

When doing operations on 'admin/product', most behavior is as expected.. if you do a POST, the product is inserted, if PATCH, the fields supplied update the existing record, if DELETE, the product is deleted.

Except for the images field. If you supply a list of images to a patch, it does not replace the previous list of images. Instead, the images are inserted alongside the existing images.

In my application I have a back-end system which contains all the product data including images and periodically I want to update oscar with any new products or changes to old products.. this includes images.

The problem is that when I do a PATCH of the product, it does not delete any existing product images that are no longer valid. The result is a superset of old and new images.

The only workaround I have found for this is to DELETE and then POST.. which is bad because it changes the URL of the product, breaking any links, search engine indexes, bookmarks, etc...

Thanks
Ben

Ok I see, thank you I will try it now.

In my view, specifying "images" in a patch should semantically speaking replace the old value of "images". But since I'm updating the whole record anyway, using PUT should be fine.

If we would do it like that, there would be no way to partially update the images.