couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [16/50] [abbrv] couchdb-mango git commit: Add Unit Test For In Operator Array
Date Tue, 03 Feb 2015 15:13:23 GMT
Add Unit Test For In Operator Array

38863-in-operatory-arrays


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

Branch: refs/heads/master
Commit: c09d8d4b2cfc12b6aac1f1e6ac8cd965811c3223
Parents: 52544a5
Author: Tony Sun <llamage@Tonys-MacBook-Pro.local>
Authored: Wed Nov 5 10:02:59 2014 -0800
Committer: Tony Sun <llamage@Tonys-MacBook-Pro.local>
Committed: Wed Nov 5 10:41:30 2014 -0800

----------------------------------------------------------------------
 src/mango_selector.erl   |  5 -----
 test/03-operator-test.py | 12 ++++++++++++
 2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/c09d8d4b/src/mango_selector.erl
----------------------------------------------------------------------
diff --git a/src/mango_selector.erl b/src/mango_selector.erl
index 97f4123..da6a8ba 100644
--- a/src/mango_selector.erl
+++ b/src/mango_selector.erl
@@ -658,11 +658,6 @@ match({[{<<"$in">>, Args}]}, Values, Cmp) when is_list(Values)->
         end, false, Values)
     end,
     lists:any(Pred, Args);
-match({[{<<"$in">>, Args}]}, Values, Cmp) when is_list(Values)->
-    Pred = fun(Arg) -> lists:foldl(fun(Value,Match) ->
-        (Cmp(Value, Arg) == 0) or Match end, false, Values)
-    end,
-    lists:any(Pred, Args);
 match({[{<<"$in">>, Args}]}, Value, Cmp) ->
     Pred = fun(Arg) -> Cmp(Value, Arg) == 0 end,
     lists:any(Pred, Args);

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/c09d8d4b/test/03-operator-test.py
----------------------------------------------------------------------
diff --git a/test/03-operator-test.py b/test/03-operator-test.py
index 6ee596a..4ef93ff 100644
--- a/test/03-operator-test.py
+++ b/test/03-operator-test.py
@@ -67,3 +67,15 @@ def test_regex():
     assert len(docs) == 2
     assert docs[0]["user_id"] == 2
     assert docs[1]["user_id"] == 10
+
+
+def test_in_operator_array():
+    db = user_docs.mkdb()
+
+    docs = db.find({
+            "manager": True,
+            "favorites": {"$in": ["Ruby", "Python"]}
+        })
+    assert len(docs) == 7
+    assert docs[0]["user_id"] == 2
+    assert docs[1]["user_id"] == 12


Mime
View raw message