couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject couchdb-mango git commit: Remove public db record
Date Wed, 01 Feb 2017 23:13:24 GMT
Repository: couchdb-mango
Updated Branches:
  refs/heads/COUCHDB-3288-remove-public-db-record [created] 293b118f0


Remove public db record

COUCHDB-3288


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

Branch: refs/heads/COUCHDB-3288-remove-public-db-record
Commit: 293b118f03f71acc37f4e172e98c83a0c6fbd612
Parents: 4afd60e
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Feb 1 17:13:08 2017 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Wed Feb 1 17:13:08 2017 -0600

----------------------------------------------------------------------
 src/mango_crud.erl        | 2 +-
 src/mango_cursor_text.erl | 4 ++--
 src/mango_httpd.erl       | 3 ++-
 src/mango_idx.erl         | 6 +++---
 src/mango_idx_text.erl    | 9 ++++++---
 5 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/293b118f/src/mango_crud.erl
----------------------------------------------------------------------
diff --git a/src/mango_crud.erl b/src/mango_crud.erl
index 68c9d6c..41a4d14 100644
--- a/src/mango_crud.erl
+++ b/src/mango_crud.erl
@@ -111,7 +111,7 @@ maybe_add_user_ctx(Db, Opts) ->
         {user_ctx, _} ->
             Opts;
         false ->
-            [{user_ctx, Db#db.user_ctx} | Opts]
+            [{user_ctx, couch_db:get_user_ctx(Db)} | Opts]
     end.
 
 

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/293b118f/src/mango_cursor_text.erl
----------------------------------------------------------------------
diff --git a/src/mango_cursor_text.erl b/src/mango_cursor_text.erl
index a094b55..59e8b48 100644
--- a/src/mango_cursor_text.erl
+++ b/src/mango_cursor_text.erl
@@ -48,7 +48,7 @@ create(Db, Indexes, Selector, Opts0) ->
             ?MANGO_ERROR(multiple_text_indexes)
     end,
 
-    Opts = unpack_bookmark(Db#db.name, Opts0),
+    Opts = unpack_bookmark(couch_db:name(Db), Opts0),
 
     DreyfusLimit = get_dreyfus_limit(),
     Limit = erlang:min(DreyfusLimit, couch_util:get_value(limit, Opts, mango_opts:default_limit())),
@@ -94,7 +94,7 @@ execute(Cursor, UserFun, UserAcc) ->
     },
     CAcc = #cacc{
         selector = Selector,
-        dbname = Db#db.name,
+        dbname = couch_db:name(Db),
         ddocid = ddocid(Idx),
         idx_name = mango_idx:name(Idx),
         bookmark = get_bookmark(Opts),

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/293b118f/src/mango_httpd.erl
----------------------------------------------------------------------
diff --git a/src/mango_httpd.erl b/src/mango_httpd.erl
index a088276..cc6cbd5 100644
--- a/src/mango_httpd.erl
+++ b/src/mango_httpd.erl
@@ -190,7 +190,8 @@ handle_find_req(Req, _Db) ->
 
 
 set_user_ctx(#httpd{user_ctx=Ctx}, Db) ->
-    Db#db{user_ctx=Ctx}.
+    {ok, NewDb} = couch_db:set_user_ctx(Db, Ctx),
+    NewDb.
 
 
 get_idx_w_opts(Opts) ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/293b118f/src/mango_idx.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx.erl b/src/mango_idx.erl
index bc88b97..1c3924a 100644
--- a/src/mango_idx.erl
+++ b/src/mango_idx.erl
@@ -290,12 +290,12 @@ idx_mod(#idx{type = <<"text">>}) ->
     end.
 
 
-db_to_name(#db{name=Name}) ->
-    Name;
 db_to_name(Name) when is_binary(Name) ->
     Name;
 db_to_name(Name) when is_list(Name) ->
-    iolist_to_binary(Name).
+    iolist_to_binary(Name);
+db_to_name(Db) ->
+    couch_db:name(Db).
 
 
 get_idx_def(Opts) ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/293b118f/src/mango_idx_text.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx_text.erl b/src/mango_idx_text.erl
index 4cfda5a..7207391 100644
--- a/src/mango_idx_text.erl
+++ b/src/mango_idx_text.erl
@@ -330,8 +330,9 @@ indexable_fields(Fields, {op_default, _}) ->
     [<<"$default">> | Fields].
 
 
-maybe_reject_index_all_req({Def}, #db{name=DbName, user_ctx=Ctx}) ->
-    User = Ctx#user_ctx.name,
+maybe_reject_index_all_req({Def}, Db) ->
+    DbName = couch_db:name(Db),
+    #user_ctx{name = User} = couch_db:get_user_ctx(Db),
     Fields = couch_util:get_value(fields, Def),
     case {Fields, forbid_index_all()} of
         {all_fields, "true"} ->
@@ -360,7 +361,9 @@ setup() ->
         end),
     %default index all def that generates {fields, all_fields}
     Index = #idx{def={[]}},
-    Db = #db{name = <<"testdb">>, user_ctx=#user_ctx{name = <<"u1">>}},
+    DbName = <<"testdb">>,
+    UserCtx = #user_ctx{name = <<"u1">>},
+    {ok, Db} = couch_db:clustered_db(DbName, UserCtx),
     {Index, Db}.
 
 


Mime
View raw message