You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/04/03 18:07:49 UTC

[GitHub] Antonio-Maranhao closed pull request #1071: Only use update and stable query params when set

Antonio-Maranhao closed pull request #1071: Only use update and stable query params when set
URL: https://github.com/apache/couchdb-fauxton/pull/1071
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/app/addons/documents/__tests__/reducers.test.js b/app/addons/documents/__tests__/reducers.test.js
index f9a08d9af..fb36b2802 100644
--- a/app/addons/documents/__tests__/reducers.test.js
+++ b/app/addons/documents/__tests__/reducers.test.js
@@ -482,5 +482,51 @@ describe('Docs Reducers', () => {
         group_level: 2
       });
     });
+
+    it('only adds update when set to non-default value in the queryOptionsPanel', () => {
+      const action = {
+        type: ActionTypes.INDEX_RESULTS_REDUX_NEW_QUERY_OPTIONS,
+        options: {
+          update: 'lazy'
+        }
+      };
+
+      const newStateLazy = Reducers.default(initialState, action);
+      expect(Reducers.getQueryOptionsParams(newStateLazy)).toEqual({
+        update: 'lazy'
+      });
+
+      action.options.update = 'false';
+      const newStateFalse = Reducers.default(initialState, action);
+      expect(Reducers.getQueryOptionsParams(newStateFalse)).toEqual({
+        update: 'false'
+      });
+
+      action.options.update = 'true';
+      const newStateTrue = Reducers.default(initialState, action);
+      expect(Reducers.getQueryOptionsParams(newStateTrue)).toEqual({
+        update: undefined
+      });
+    });
+
+    it('only adds stable when set to non-default value in the queryOptionsPanel', () => {
+      const action = {
+        type: ActionTypes.INDEX_RESULTS_REDUX_NEW_QUERY_OPTIONS,
+        options: {
+          stable: true
+        }
+      };
+
+      const newStateTrue = Reducers.default(initialState, action);
+      expect(Reducers.getQueryOptionsParams(newStateTrue)).toEqual({
+        stable: true
+      });
+
+      action.options.stable = false;
+      const newStateFalse = Reducers.default(initialState, action);
+      expect(Reducers.getQueryOptionsParams(newStateFalse)).toEqual({
+        stable: undefined
+      });
+    });
   });
 });
diff --git a/app/addons/documents/index-results/reducers.js b/app/addons/documents/index-results/reducers.js
index 22d984bcd..b37b85d38 100644
--- a/app/addons/documents/index-results/reducers.js
+++ b/app/addons/documents/index-results/reducers.js
@@ -322,12 +322,21 @@ export const getQueryOptionsParams = (state) => {
     }
   }
 
+  // Only add UPDATE and STABLE parameters when different than
+  // their respective default values. This prevent errors in
+  // older CouchDB versions that don't support these parameters.
   if (queryOptionsPanel.update !== undefined) {
-    params.update = queryOptionsPanel.update;
+    // Default value is 'true'
+    if (queryOptionsPanel.update !== 'true') {
+      params.update = queryOptionsPanel.update;
+    }
   }
 
   if (typeof queryOptionsPanel.stable === 'boolean') {
-    params.stable = queryOptionsPanel.stable;
+    // Default value is false
+    if (queryOptionsPanel.stable === true) {
+      params.stable = queryOptionsPanel.stable;
+    }
   }
 
   return params;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services