Fix $all operator

The $all operator was only returning docs where the field exactly
matched the array. It should return docs where the provided matching
array is a subset of the field's array.
Ex: {"field" :
        { "$all" : ["Bob", "Joe"] }
    }
should match "field" : ["Bob", "Jane", "Joe"]

BugzId:46731


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

Branch: refs/heads/master
Commit: e80608da4f51ce787343a6721a4c44d1f489373c
Parents: cdc9fe5
Author: Tony Sun <tony....@cloudant.com>
Authored: Tue Aug 25 13:18:07 2015 -0700
Committer: Tony Sun <tony....@cloudant.com>
Committed: Tue Aug 25 13:24:04 2015 -0700

----------------------------------------------------------------------
 src/mango_selector_text.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/e80608da/src/mango_selector_text.erl
----------------------------------------------------------------------
diff --git a/src/mango_selector_text.erl b/src/mango_selector_text.erl
index 9402cc2..5eb237f 100644
--- a/src/mango_selector_text.erl
+++ b/src/mango_selector_text.erl
@@ -71,7 +71,7 @@ convert(Path, {[{<<"$all">>, Args}]}) ->
         _ ->
             % Otherwise the $all operator is equivalent to an $and
             % operator so we treat it as such.
-            convert(Path, {[{<<"$eq">> , Args}]})
+            convert([<<"[]">>| Path], {[{<<"$and">>, Args}]})
     end;
 
 % The $elemMatch Lucene query is not an exact translation

Reply via email to