couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [couchdb] branch master updated: Do not always return partial_filter_selector (#951)
Date Wed, 01 Nov 2017 15:45:34 GMT
This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 2e49d7c  Do not always return partial_filter_selector (#951)
2e49d7c is described below

commit 2e49d7cf9b7fdcd597c8d806e5530047051f1250
Author: garren smith <garren.smith@gmail.com>
AuthorDate: Wed Nov 1 17:45:32 2017 +0200

    Do not always return partial_filter_selector (#951)
    
    For Get / _index only return the partial_filter_selector for an index if
    it is set to something other than default
---
 src/mango/src/mango_idx_text.erl          |  4 ++++
 src/mango/src/mango_idx_view.erl          |  4 ++++
 src/mango/test/16-index-selectors-test.py | 13 ++++++++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/mango/src/mango_idx_text.erl b/src/mango/src/mango_idx_text.erl
index e4ffc91..1d5ae9b 100644
--- a/src/mango/src/mango_idx_text.erl
+++ b/src/mango/src/mango_idx_text.erl
@@ -152,6 +152,10 @@ def_to_json([{fields, Fields} | Rest]) ->
     [{<<"fields">>, fields_to_json(Fields)} | def_to_json(Rest)];
 def_to_json([{<<"fields">>, Fields} | Rest]) ->
     [{<<"fields">>, fields_to_json(Fields)} | def_to_json(Rest)];
+% Don't include partial_filter_selector in the json conversion
+% if its the default value
+def_to_json([{<<"partial_filter_selector">>, {[]}} | Rest]) ->
+    def_to_json(Rest);
 def_to_json([{Key, Value} | Rest]) ->
     [{Key, Value} | def_to_json(Rest)].
 
diff --git a/src/mango/src/mango_idx_view.erl b/src/mango/src/mango_idx_view.erl
index f1041bb..c9fe4c8 100644
--- a/src/mango/src/mango_idx_view.erl
+++ b/src/mango/src/mango_idx_view.erl
@@ -195,6 +195,10 @@ def_to_json([{fields, Fields} | Rest]) ->
     [{<<"fields">>, mango_sort:to_json(Fields)} | def_to_json(Rest)];
 def_to_json([{<<"fields">>, Fields} | Rest]) ->
     [{<<"fields">>, mango_sort:to_json(Fields)} | def_to_json(Rest)];
+% Don't include partial_filter_selector in the json conversion
+% if its the default value
+def_to_json([{<<"partial_filter_selector">>, {[]}} | Rest]) ->
+    def_to_json(Rest);
 def_to_json([{Key, Value} | Rest]) ->
     [{Key, Value} | def_to_json(Rest)].
 
diff --git a/src/mango/test/16-index-selectors-test.py b/src/mango/test/16-index-selectors-test.py
index 456b396..6d771cc 100644
--- a/src/mango/test/16-index-selectors-test.py
+++ b/src/mango/test/16-index-selectors-test.py
@@ -161,6 +161,11 @@ class IndexSelectorJson(mango.DbPerClass):
         indexes = self.db.list_indexes()
         self.assertEqual(indexes[1]["def"]["partial_filter_selector"], selector)
 
+    def test_partial_filter_only_in_return_if_not_default(self):
+        self.db.create_index(["location"])
+        index = self.db.list_indexes()[1]
+        self.assertEqual('partial_filter_selector' in index['def'], False)
+
     def test_saves_selector_in_index_throws(self):
         selector = {"location": {"$gte": "FRA"}}
         try:
@@ -264,4 +269,10 @@ class IndexSelectorJson(mango.DbPerClass):
         resp = self.db.find(selector, explain=True, use_index='oldschooltext')
         self.assertEqual(resp["index"]["name"], "oldschooltext")
         docs = self.db.find(selector, use_index='oldschooltext')
-        self.assertEqual(len(docs), 3)
\ No newline at end of file
+        self.assertEqual(len(docs), 3)
+
+    @unittest.skipUnless(mango.has_text_service(), "requires text service")
+    def test_text_partial_filter_only_in_return_if_not_default(self):
+        self.db.create_text_index(fields=[{"name":"location"}])
+        index = self.db.list_indexes()[1]
+        self.assertEqual('partial_filter_selector' in index['def'], False)

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <commits@couchdb.apache.org>'].

Mime
View raw message