You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/10/23 13:22:31 UTC

[GitHub] garrensmith closed pull request #1668: expose is_systemdb_name

garrensmith closed pull request #1668: expose is_systemdb_name
URL: https://github.com/apache/couchdb/pull/1668
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 4d76ceedcb..57e3951797 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -56,6 +56,7 @@
     is_db/1,
     is_system_db/1,
     is_clustered/1,
+    is_system_db_name/1,
 
     set_revs_limit/2,
     set_purge_infos_limit/2,
@@ -1729,15 +1730,15 @@ validate_dbname_int(DbName, Normalized) when is_binary(DbName) ->
         match ->
             ok;
         nomatch ->
-            case is_systemdb(Normalized) of
+            case is_system_db_name(Normalized) of
                 true -> ok;
                 false -> {error, {illegal_database_name, DbName}}
             end
     end.
 
-is_systemdb(DbName) when is_list(DbName) ->
-    is_systemdb(?l2b(DbName));
-is_systemdb(DbName) when is_binary(DbName) ->
+is_system_db_name(DbName) when is_list(DbName) ->
+    is_system_db_name(?l2b(DbName));
+is_system_db_name(DbName) when is_binary(DbName) ->
     Normalized = normalize_dbname(DbName),
     Suffix = filename:basename(Normalized),
     case {filename:dirname(Normalized), lists:member(Suffix, ?SYSTEM_DATABASES)} of
@@ -1860,7 +1861,7 @@ dbname_suffix_test_() ->
     [{test_name({Expected, Db}), ?_assertEqual(Expected, dbname_suffix(Db))}
         || {Expected, Db} <- WithExpected].
 
-is_systemdb_test_() ->
+is_system_db_name_test_() ->
     Cases = lists:append([
         generate_cases_with_shards("long/co$mplex-/path+/" ++ ?b2l(Db))
             || Db <- ?SYSTEM_DATABASES]
@@ -1869,7 +1870,7 @@ is_systemdb_test_() ->
     WithExpected = [{?l2b(filename:basename(filename:rootname(Arg))), Db}
         || {Arg, Db} <- Cases],
     [{test_name({Expected, Db}) ++ " in ?SYSTEM_DATABASES",
-        ?_assert(is_systemdb(Db))} || {Expected, Db} <- WithExpected].
+        ?_assert(is_system_db_name(Db))} || {Expected, Db} <- WithExpected].
 
 should_pass_validate_dbname(DbName) ->
     {test_name(DbName), ?_assertEqual(ok, validate_dbname(DbName))}.
diff --git a/src/couch/src/couch_doc.erl b/src/couch/src/couch_doc.erl
index f960ec5c2d..e5ad9e9f19 100644
--- a/src/couch/src/couch_doc.erl
+++ b/src/couch/src/couch_doc.erl
@@ -200,7 +200,7 @@ parse_revs(_) ->
 
 validate_docid(DocId, DbName) ->
     case DbName =:= ?l2b(config:get("mem3", "shards_db", "_dbs")) andalso
-        lists:member(DocId, ?SYSTEM_DATABASES) of
+        couch_db:is_system_db_name(DocId) of
         true ->
             ok;
         false ->


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services