Skip to content

Commit

Permalink
The default value for keys is undefined, not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
rnewson committed Feb 3, 2014
1 parent e879c67 commit cbbef5c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/chttpd/src/chttpd_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ db_req(#httpd{method='GET',path_parts=[_,<<"_all_docs">>]}=Req, Db) ->
Keys when is_list(Keys) ->
all_docs_view(Req, Db, Keys);
nil ->
all_docs_view(Req, Db, nil);
all_docs_view(Req, Db, undefined);
_ ->
throw({bad_request, "`keys` parameter must be an array."})
end;
Expand Down
6 changes: 3 additions & 3 deletions src/fabric/src/fabric_rpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
%% rpc endpoints
%% call to with_db will supply your M:F with a #db{} and then remaining args

all_docs(DbName, #mrargs{keys=nil} = QueryArgs) ->
all_docs(DbName, #mrargs{keys=undefined} = QueryArgs) ->
{ok, Db} = get_or_create_db(DbName, []),
#mrargs{
start_key = StartKey,
Expand Down Expand Up @@ -122,7 +122,7 @@ map_view(DbName, DDoc, ViewName, QueryArgs) ->
reduce_fun = fun couch_view:reduce_to_count/1
},
case Keys of
nil ->
undefined ->
Options = couch_httpd_view:make_key_options(QueryArgs),
{ok, _, Acc} = couch_view:fold(View, fun view_fold/3, Acc0, Options);
_ ->
Expand Down Expand Up @@ -163,7 +163,7 @@ reduce_view(DbName, Group0, ViewName, QueryArgs) ->
ReduceView = {reduce, NthRed, Lang, View},
Acc0 = #view_acc{group_level = GroupLevel, limit = Limit+Skip},
case Keys of
nil ->
undefined ->
Options0 = couch_httpd_view:make_key_options(QueryArgs),
Options = [{key_group_fun, GroupFun} | Options0],
couch_view:fold_reduce(ReduceView, fun reduce_fold/3, Acc0, Options);
Expand Down
2 changes: 1 addition & 1 deletion src/fabric/src/fabric_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ possibly_embed_doc(#collector{db_name=DbName, query_args=Args},
end.


keydict(nil) ->
keydict(undefined) ->
undefined;
keydict(Keys) ->
{Dict,_} = lists:foldl(fun(K, {D,I}) -> {dict:store(K,I,D), I+1} end,
Expand Down
2 changes: 1 addition & 1 deletion src/fabric/src/fabric_view_all_docs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-include_lib("mem3/include/mem3.hrl").
-include_lib("couch/include/couch_db.hrl").

go(DbName, #view_query_args{keys=nil} = QueryArgs, Callback, Acc0) ->
go(DbName, #view_query_args{keys=undefined} = QueryArgs, Callback, Acc0) ->
Workers = fabric_util:submit_jobs(mem3:shards(DbName),all_docs,[QueryArgs]),
#view_query_args{limit = Limit, skip = Skip} = QueryArgs,
State = #collector{
Expand Down

0 comments on commit cbbef5c

Please sign in to comment.