From bf910a2222017366e3ea216702fc9d9d5c1ef3e6 Mon Sep 17 00:00:00 2001 From: Yasir Assam Date: Wed, 10 Mar 2021 10:12:05 +1100 Subject: [PATCH] Local fix to https://github.com/SitePen/dstore/issues/218 Because this hasn't been fixed upstream, I'm fixing it here. Adding an object to a cache-backed Rest store causes what should be a POST call to turn into a PUT call with a random id. --- Cache.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Cache.js b/Cache.js index d0b5364..70bb428 100644 --- a/Cache.js +++ b/Cache.js @@ -150,7 +150,14 @@ define([ // first update the cache, we are going to assume the update is valid while we wait to // hear from the master store var cachingStore = this.cachingStore; - cachingStore.put(object, directives); + // Yasir 2021-03-10: The following cachingStore.put() has + // been commented out. See https://github.com/SitePen/dstore/issues/218 + // If you're adding a new element with a cache backed Rest store, + // the following calls adds a random ID which turns the POST in + // the following Rest call into a PUT which fails. As per the bug report above + // let Rest do its thing then update the cache afterwards. + // + // --- cachingStore.put(object, directives); return when(this.inherited(arguments)).then(function (result) { // now put result in cache var cachedPutResult =