You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/11/04 20:55:19 UTC

[couchdb] 01/01: Ensure we can create partitioned design docs with FDB

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch fix-ddoc-validation-with-fdb
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 910b2d7ffff1fef00bf3624a43f301811d9746ec
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Nov 4 15:53:58 2019 -0500

    Ensure we can create partitioned design docs with FDB
    
    Users should be able to replicate their partitioned dbs to the new environment.
---
 src/couch_mrview/src/couch_mrview.erl      | 14 ++------------
 src/fabric/test/fabric2_doc_crud_tests.erl | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/couch_mrview/src/couch_mrview.erl b/src/couch_mrview/src/couch_mrview.erl
index cf6f27f..083356f 100644
--- a/src/couch_mrview/src/couch_mrview.erl
+++ b/src/couch_mrview/src/couch_mrview.erl
@@ -184,7 +184,7 @@ validate(Db, DDoc) ->
     validate(DbName, IsPartitioned, DDoc).
 
 
-validate(DbName, IsDbPartitioned,  DDoc) ->
+validate(DbName, _IsDbPartitioned,  DDoc) ->
     ok = validate_ddoc_fields(DDoc#doc.body),
     GetName = fun
         (#mrview{map_names = [Name | _]}) -> Name;
@@ -211,19 +211,9 @@ validate(DbName, IsDbPartitioned,  DDoc) ->
     end,
     {ok, #mrst{
         language = Lang,
-        views = Views,
-        partitioned = Partitioned
+        views = Views
     }} = couch_mrview_util:ddoc_to_mrst(DbName, DDoc),
 
-    case {IsDbPartitioned, Partitioned} of
-        {false, true} ->
-            throw({invalid_design_doc,
-                <<"partitioned option cannot be true in a "
-                  "non-partitioned database.">>});
-        {_, _} ->
-            ok
-    end,
-
     try Views =/= [] andalso couch_query_servers:get_os_process(Lang) of
         false ->
             ok;
diff --git a/src/fabric/test/fabric2_doc_crud_tests.erl b/src/fabric/test/fabric2_doc_crud_tests.erl
index 255efef..a9085be 100644
--- a/src/fabric/test/fabric2_doc_crud_tests.erl
+++ b/src/fabric/test/fabric2_doc_crud_tests.erl
@@ -33,6 +33,7 @@ doc_crud_test_() ->
                 fun create_ddoc_requires_admin/1,
                 fun create_ddoc_requires_validation/1,
                 fun create_ddoc_requires_compilation/1,
+                fun can_create_a_partitioned_ddoc/1,
                 fun update_doc_basic/1,
                 fun update_ddoc_basic/1,
                 fun update_doc_replicated/1,
@@ -108,6 +109,23 @@ create_ddoc_basic({Db, _}) ->
     ?assertEqual({ok, NewDoc}, fabric2_db:open_doc(Db, Doc#doc.id)).
 
 
+can_create_a_partitioned_ddoc({Db, _}) ->
+    UUID = fabric2_util:uuid(),
+    DDocId = <<"_design/", UUID/binary>>,
+    Doc = #doc{
+        id = DDocId,
+        body = {[
+            {<<"options">>, {[{<<"partitioned">>, true}]}},
+            {<<"views">>, {[
+                {<<"foo">>, {[
+                    {<<"map">>, <<"function(doc) {}">>}
+                ]}}
+            ]}}
+        ]}
+    },
+    ?assertMatch({ok, {_, _}}, fabric2_db:update_doc(Db, Doc)).
+
+
 create_ddoc_requires_admin({Db, _}) ->
     Db2 = fabric2_db:set_user_ctx(Db, #user_ctx{}),
     UUID = fabric2_util:uuid(),