couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From willhol...@apache.org
Subject [couchdb] branch master updated: Fix user-specified ddoc name in Mango (#961)
Date Fri, 03 Nov 2017 14:08:52 GMT
This is an automated email from the ASF dual-hosted git repository.

willholley 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 436b402  Fix user-specified ddoc name in Mango (#961)
436b402 is described below

commit 436b402721b26575e989f04db61c9edbcfb168f5
Author: Will Holley <willholley@gmail.com>
AuthorDate: Fri Nov 3 14:08:50 2017 +0000

    Fix user-specified ddoc name in Mango (#961)
    
    When creating a Mango index, we allow the user to specify
    a design document name. This can be of the form "_design/foo"
    or just "foo", with the expectation that Mango would
    automatically add the "_design" prefix.
    
    This fixes a bug whereby if the user specified "_design/foo",
    Mango was prefixing this again, creating a design document called
    "_design/_design/foo".
---
 src/mango/src/mango_idx.erl | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/mango/src/mango_idx.erl b/src/mango/src/mango_idx.erl
index 4dd2e18..8e19ebf 100644
--- a/src/mango/src/mango_idx.erl
+++ b/src/mango/src/mango_idx.erl
@@ -333,7 +333,7 @@ get_idx_type(Opts) ->
 
 get_idx_ddoc(Idx, Opts) ->
     case proplists:get_value(ddoc, Opts) of
-        <<"_design/", _Rest>> = Name ->
+        <<"_design/", _Rest/binary>> = Name ->
             Name;
         Name when is_binary(Name) ->
             <<"_design/", Name/binary>>;
@@ -437,4 +437,13 @@ get_partial_filter_selector_with_legacy_default_selector_test() ->
     Idx = index(<<"selector">>, []),
     ?assertEqual(undefined, get_partial_filter_selector(Idx)).
 
+
+get_idx_ddoc_name_only_test() ->
+    Opts = [{ddoc, <<"foo">>}],
+    ?assertEqual(<<"_design/foo">>, get_idx_ddoc({}, Opts)).
+
+get_idx_ddoc_design_slash_name_test() ->
+    Opts = [{ddoc, <<"_design/foo">>}],
+    ?assertEqual(<<"_design/foo">>, get_idx_ddoc({}, Opts)).
+
 -endif.

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

Mime
View raw message