You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2016/08/02 17:24:38 UTC

couchdb-mango git commit: Add op_field term to fix special $or case

Repository: couchdb-mango
Updated Branches:
  refs/heads/upstream [created] 1a4215678


Add op_field term to fix special $or case

We're missing the term op_field when recursively calling
indexable_fields in a special case. This leads to a function_clause
error when specifically two elements are used in a $or query. It works
when they index all fields because indexable_fields is not called.
However, when the user specifically indexes a field, we encounter this
error. Inserting the op_field term  allows the function to be called
correctly.

BugzId: 71037


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/1a421567
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/1a421567
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/1a421567

Branch: refs/heads/upstream
Commit: 1a421567886a039628e3ec66d44a515ec324d26d
Parents: 01252f9
Author: Tony Sun <to...@cloudant.com>
Authored: Thu Jul 28 18:36:37 2016 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Thu Jul 28 18:36:37 2016 -0700

----------------------------------------------------------------------
 src/mango_idx_text.erl                 | 2 +-
 test/07-text-custom-field-list-test.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/1a421567/src/mango_idx_text.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx_text.erl b/src/mango_idx_text.erl
index 5528915..40a1fd3 100644
--- a/src/mango_idx_text.erl
+++ b/src/mango_idx_text.erl
@@ -294,7 +294,7 @@ indexable_fields(Fields, {op_or, [{op_field, Field0},
         true ->
             indexable_fields(Fields, Field1);
         false ->
-            Fields1 = indexable_fields(Fields, Field0),
+            Fields1 = indexable_fields(Fields, {op_field, Field0}),
             indexable_fields(Fields1, Field1)
     end;
 indexable_fields(Fields, {op_or, Args}) when is_list(Args) ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/1a421567/test/07-text-custom-field-list-test.py
----------------------------------------------------------------------
diff --git a/test/07-text-custom-field-list-test.py b/test/07-text-custom-field-list-test.py
index 73d870b..029c91c 100644
--- a/test/07-text-custom-field-list-test.py
+++ b/test/07-text-custom-field-list-test.py
@@ -139,3 +139,9 @@ class CustomFieldsTest(mango.UserDocsTextTests):
         docs = self.db.find({"age": 22}, fields = ["all_fields"])
         assert len(docs) == 1
         assert docs == [{}]
+
+    def test_two_or(self):
+        docs = self.db.find({"$or": [{"location.state": "New Hampshire"},
+            {"location.state": "Don't Exist"}]})
+        assert len(docs) == 1
+        assert docs[0]["user_id"] == 10