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 2015/09/04 00:33:42 UTC

[1/4] couchdb-mango git commit: Use module_loaded instead of module_info

Repository: couchdb-mango
Updated Branches:
  refs/heads/2787-merge-repos 6100a0b68 -> f12076f24


Use module_loaded instead of module_info

COUCHDB-2787


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

Branch: refs/heads/2787-merge-repos
Commit: 874e8d2a74f83e19aedfd0acb1e562f918844c99
Parents: 6100a0b
Author: Tony Sun <to...@cloudant.com>
Authored: Thu Sep 3 13:01:33 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Thu Sep 3 13:01:33 2015 -0700

----------------------------------------------------------------------
 src/mango_cursor.erl |  2 +-
 src/mango_idx.erl    |  8 ++++----
 src/mango_util.erl   | 17 +----------------
 3 files changed, 6 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/874e8d2a/src/mango_cursor.erl
----------------------------------------------------------------------
diff --git a/src/mango_cursor.erl b/src/mango_cursor.erl
index d73761e..6cb7fee 100644
--- a/src/mango_cursor.erl
+++ b/src/mango_cursor.erl
@@ -123,7 +123,7 @@ group_indexes_by_type(Indexes) ->
     % used to service this query. This is so that we
     % don't suddenly switch indexes for existing client
     % queries.
-    CursorModules = case mango_util:module_exists(dreyfus_index) of
+    CursorModules = case module_loaded(dreyfus_index) of
         true ->
             [mango_cursor_view, mango_cursor_text];
         false ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/874e8d2a/src/mango_idx.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx.erl b/src/mango_idx.erl
index 6f73af1..56b7fc2 100644
--- a/src/mango_idx.erl
+++ b/src/mango_idx.erl
@@ -166,7 +166,7 @@ from_ddoc(Db, {Props}) ->
         _ ->
             ?MANGO_ERROR(invalid_query_ddoc_language)
     end,
-    IdxMods = case mango_util:module_exists(dreyfus_index) of
+    IdxMods = case module_loaded(dreyfus_index) of
         true ->
             [mango_idx_view, mango_idx_text];
         false ->
@@ -247,7 +247,7 @@ cursor_mod(#idx{type = <<"json">>}) ->
 cursor_mod(#idx{def = all_docs, type= <<"special">>}) ->
     mango_cursor_view;
 cursor_mod(#idx{type = <<"text">>}) ->
-    case mango_util:module_exists(dreyfus_index) of
+    case module_loaded(dreyfus_index) of
         true ->
             mango_cursor_text;
         false ->
@@ -260,7 +260,7 @@ idx_mod(#idx{type = <<"json">>}) ->
 idx_mod(#idx{type = <<"special">>}) ->
     mango_idx_special;
 idx_mod(#idx{type = <<"text">>}) ->
-    case mango_util:module_exists(dreyfus_index) of
+    case module_loaded(dreyfus_index) of
         true ->
             mango_idx_text;
         false ->
@@ -288,7 +288,7 @@ get_idx_def(Opts) ->
 get_idx_type(Opts) ->
     case proplists:get_value(type, Opts) of
         <<"json">> -> <<"json">>;
-        <<"text">> -> case mango_util:module_exists(dreyfus_index) of
+        <<"text">> -> case module_loaded(dreyfus_index) of
             true ->
                 <<"text">>;
             false ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/874e8d2a/src/mango_util.erl
----------------------------------------------------------------------
diff --git a/src/mango_util.erl b/src/mango_util.erl
index 553535d..c3513dc 100644
--- a/src/mango_util.erl
+++ b/src/mango_util.erl
@@ -42,9 +42,7 @@
 
     parse_field/1,
 
-    cached_re/2,
-
-    module_exists/1
+    cached_re/2
 ]).
 
 
@@ -397,19 +395,6 @@ check_non_empty(Field, Parts) ->
             Parts
     end.
 
-module_exists(Module) ->
-    case is_atom(Module) of
-        true ->
-            try Module:module_info() of
-                _InfoList ->
-                    true
-            catch
-                _:_ ->
-                    false
-            end;
-        false ->
-            false
-    end.
 
 -ifdef(TEST).
 -include_lib("eunit/include/eunit.hrl").


[2/4] couchdb-mango git commit: Use config:get_integer

Posted by to...@apache.org.
Use config:get_integer

COUCHDB-2787


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

Branch: refs/heads/2787-merge-repos
Commit: 928d76ac2c2739a25313e281cfeb1ac485070054
Parents: 874e8d2
Author: Tony Sun <to...@cloudant.com>
Authored: Thu Sep 3 15:26:27 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Thu Sep 3 15:26:27 2015 -0700

----------------------------------------------------------------------
 src/mango_cursor_text.erl              |  2 +-
 test/01-index-crud-test.py             |  8 +++---
 test/04-key-tests.py                   |  2 +-
 test/05-index-selection-test.py        |  4 +--
 test/06-basic-text-test.py             | 38 ++++++++++++++---------------
 test/06-text-default-field-test.py     | 18 +++++++-------
 test/07-text-custom-field-list-test.py |  6 ++---
 test/08-text-limit-test.py             |  6 ++---
 test/09-text-sort-test.py              |  6 ++---
 test/mango.py                          |  3 +--
 10 files changed, 46 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/src/mango_cursor_text.erl
----------------------------------------------------------------------
diff --git a/src/mango_cursor_text.erl b/src/mango_cursor_text.erl
index ec83240..971d153 100644
--- a/src/mango_cursor_text.erl
+++ b/src/mango_cursor_text.erl
@@ -284,7 +284,7 @@ get_limit(CAcc) ->
 
 
 get_dreyfus_limit() ->
-    list_to_integer(config:get("dreyfus", "max_limit", "200")).
+    config:get_integer("dreyfus", "max_limit", 200).
 
 
 get_json_docs(DbName, Hits) ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/01-index-crud-test.py
----------------------------------------------------------------------
diff --git a/test/01-index-crud-test.py b/test/01-index-crud-test.py
index 021d66e..2852a6a 100644
--- a/test/01-index-crud-test.py
+++ b/test/01-index-crud-test.py
@@ -16,10 +16,10 @@ import mango
 import unittest
 
 class IndexCrudTests(mango.DbPerClass):
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
-        super(KeyTests, klass).setUpClass()
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service not available')
+    #     super(KeyTests, klass).setUpClass()
 
     def test_bad_fields(self):
         bad_fields = [

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/04-key-tests.py
----------------------------------------------------------------------
diff --git a/test/04-key-tests.py b/test/04-key-tests.py
index 5174d0b..9b55c7f 100644
--- a/test/04-key-tests.py
+++ b/test/04-key-tests.py
@@ -56,7 +56,7 @@ TEST_DOCS = [
 class KeyTests(mango.DbPerClass):
     @classmethod
     def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
+        # raise unittest.SkipTest('text index service not available')
         super(KeyTests, klass).setUpClass()
         klass.db.save_docs(TEST_DOCS, w=3)
         klass.db.create_index(["type"], ddoc="view")

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/05-index-selection-test.py
----------------------------------------------------------------------
diff --git a/test/05-index-selection-test.py b/test/05-index-selection-test.py
index 4ded668..375085f 100644
--- a/test/05-index-selection-test.py
+++ b/test/05-index-selection-test.py
@@ -19,7 +19,7 @@ class IndexSelectionTests(mango.UserDocsTests):
     @classmethod
     def setUpClass(klass):
         super(IndexSelectionTests, klass).setUpClass()
-        # user_docs.add_text_indexes(klass.db, {})
+        user_docs.add_text_indexes(klass.db, {})
 
     def test_basic(self):
         resp = self.db.find({"name.last": "A last name"}, explain=True)
@@ -77,7 +77,7 @@ class IndexSelectionTests(mango.UserDocsTests):
 class MultiTextIndexSelectionTests(mango.UserDocsTests):
     @classmethod
     def setUpClass(klass):
-        raise unittest.SkipTest('text index service is not available')
+        # raise unittest.SkipTest('text index service is not available')
         super(MultiTextIndexSelectionTests, klass).setUpClass()
         klass.db.create_text_index(ddoc="foo", analyzer="keyword")
         klass.db.create_text_index(ddoc="bar", analyzer="email")

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/06-basic-text-test.py
----------------------------------------------------------------------
diff --git a/test/06-basic-text-test.py b/test/06-basic-text-test.py
index 72a3918..593e6d7 100644
--- a/test/06-basic-text-test.py
+++ b/test/06-basic-text-test.py
@@ -17,24 +17,24 @@ import user_docs
 import num_string_docs
 
 
-class TextIndexCheckTests(mango.DbPerClass):
+# class TextIndexCheckTests(mango.DbPerClass):
 
-    def test_create_text_index(self):
-        body = json.dumps({
-            'index': {
-                'fields': 'test'
-            },
-            'type': 'text'
-        })
-        resp = self.db.sess.post(self.db.path("_index"), data=body)
-        assert resp.status_code == 503, resp
+#     def test_create_text_index(self):
+#         body = json.dumps({
+#             'index': {
+#                 'fields': 'test'
+#             },
+#             'type': 'text'
+#         })
+#         resp = self.db.sess.post(self.db.path("_index"), data=body)
+#         assert resp.status_code == 503, resp
 
 
 class BasicTextTests(mango.UserDocsTextTests):
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service not available')
 
     def test_simple(self):
         docs = self.db.find({"$text": "Stephanie"})
@@ -431,9 +431,9 @@ class BasicTextTests(mango.UserDocsTextTests):
 
 class ElemMatchTests(mango.FriendDocsTextTests):
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service not available')
 
     def test_elem_match_non_object(self):
         q = {"bestfriends":{
@@ -566,9 +566,9 @@ class ElemMatchTests(mango.FriendDocsTextTests):
 # Test numeric strings for $text
 class NumStringTests(mango.NumStringDocsTextTests):
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service not available')
 
     def test_floating_point_val(self):
         float_point_string = num_string_docs.DOCS[2]["number_string"]

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/06-text-default-field-test.py
----------------------------------------------------------------------
diff --git a/test/06-text-default-field-test.py b/test/06-text-default-field-test.py
index f4aaf9a..599cad6 100644
--- a/test/06-text-default-field-test.py
+++ b/test/06-text-default-field-test.py
@@ -18,9 +18,9 @@ class NoDefaultFieldTest(mango.UserDocsTextTests):
 
     DEFAULT_FIELD = False
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service not available')
 
     def test_basic(self):
         docs = self.db.find({"$text": "Ramona"})
@@ -40,9 +40,9 @@ class NoDefaultFieldWithAnalyzer(mango.UserDocsTextTests):
         "analyzer": "keyword"
     }
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text not supported')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text not supported')
 
     def test_basic(self):
         docs = self.db.find({"$text": "Ramona"})
@@ -61,9 +61,9 @@ class DefaultFieldWithCustomAnalyzer(mango.UserDocsTextTests):
         "analyzer": "keyword"
     }
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text not supported')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text not supported')
 
     def test_basic(self):
         docs = self.db.find({"$text": "Ramona"})

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/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 8d68a1f..c59c3a2 100644
--- a/test/07-text-custom-field-list-test.py
+++ b/test/07-text-custom-field-list-test.py
@@ -16,9 +16,9 @@ import unittest
 
 class CustomFieldsTest(mango.UserDocsTextTests):
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service not available')
 
     FIELDS = [
         {"name": "favorites.[]", "type": "string"},

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/08-text-limit-test.py
----------------------------------------------------------------------
diff --git a/test/08-text-limit-test.py b/test/08-text-limit-test.py
index 36bf4a9..31083ae 100644
--- a/test/08-text-limit-test.py
+++ b/test/08-text-limit-test.py
@@ -16,9 +16,9 @@ import unittest
 
 class LimitTests(mango.LimitDocsTextTests):
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service not available')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service not available')
 
     def test_limit_field(self):
         q = {"$or": [{"user_id" : {"$lt" : 10}}, {"filtered_array.[]": 1}]}

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/09-text-sort-test.py
----------------------------------------------------------------------
diff --git a/test/09-text-sort-test.py b/test/09-text-sort-test.py
index 7bdf54a..c06c680 100644
--- a/test/09-text-sort-test.py
+++ b/test/09-text-sort-test.py
@@ -15,9 +15,9 @@ import unittest
 
 class SortTests(mango.UserDocsTextTests):
 
-    @classmethod
-    def setUpClass(klass):
-        raise unittest.SkipTest('text index service is not available')
+    # @classmethod
+    # def setUpClass(klass):
+    #     raise unittest.SkipTest('text index service is not available')
 
     def test_number_sort(self):
         q = {"age": {"$gt": 0}}

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/928d76ac/test/mango.py
----------------------------------------------------------------------
diff --git a/test/mango.py b/test/mango.py
index 6764ed5..3464b14 100644
--- a/test/mango.py
+++ b/test/mango.py
@@ -33,8 +33,7 @@ class Database(object):
         self.port = port
         self.dbname = dbname
         self.sess = requests.session()
-        if auth is not None:
-            self.sess.auth = auth
+        self.sess.auth = ('adm', 'pass')
         self.sess.headers["Content-Type"] = "application/json"
 
     @property


[3/4] couchdb-mango git commit: Use short circuit operators

Posted by to...@apache.org.
Use short circuit operators

COUCHDB-2787


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

Branch: refs/heads/2787-merge-repos
Commit: 8b6d0dbd3540cf34d9703526ba0b0b6d3226ff8d
Parents: 928d76a
Author: Tony Sun <to...@cloudant.com>
Authored: Thu Sep 3 15:26:59 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Thu Sep 3 15:26:59 2015 -0700

----------------------------------------------------------------------
 src/mango_idx_view.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/8b6d0dbd/src/mango_idx_view.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx_view.erl b/src/mango_idx_view.erl
index a313f56..cc5bcb3 100644
--- a/src/mango_idx_view.erl
+++ b/src/mango_idx_view.erl
@@ -112,7 +112,7 @@ is_usable(Idx, Selector) ->
     % a member of the indexable fields of the selector.
     Columns = columns(Idx),
     Fields = indexable_fields(Selector),
-    lists:member(hd(Columns), Fields) and not is_text_search(Selector).
+    lists:member(hd(Columns), Fields) andalso not is_text_search(Selector).
 
 
 is_text_search({[]}) ->
@@ -121,7 +121,7 @@ is_text_search({[{<<"$default">>, _}]}) ->
     true;
 is_text_search({[{_Field, Cond}]}) when is_list(Cond) ->
     lists:foldl(fun(C, Exists) ->
-        Exists or is_text_search(C)
+        Exists orelse is_text_search(C)
     end, false, Cond);
 is_text_search({[{_Field, Cond}]}) when is_tuple(Cond) ->
     is_text_search(Cond);


[4/4] couchdb-mango git commit: Remove extraneous error message

Posted by to...@apache.org.
Remove extraneous error message

COUCHDB-2787


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

Branch: refs/heads/2787-merge-repos
Commit: f12076f24a4d2cf7ae500dd6c15735ef24f1d5cf
Parents: 8b6d0db
Author: Tony Sun <to...@cloudant.com>
Authored: Thu Sep 3 15:30:19 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Thu Sep 3 15:30:19 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/f12076f2/src/mango_error.erl
----------------------------------------------------------------------
diff --git a/src/mango_error.erl b/src/mango_error.erl
index 4704261..9b7ae82 100644
--- a/src/mango_error.erl
+++ b/src/mango_error.erl
@@ -69,7 +69,7 @@ info(mango_cursor_text, {text_search_error, {error, Error}}) ->
     {
         400,
         <<"text_search_error">>,
-        fmt("Error performing text search: ~p", [Error])
+        fmt("~p", [Error])
     };
 
 info(mango_fields, {invalid_fields_json, BadFields}) ->