davisp commented on a change in pull request #1110: Make _design_docs to
respect query parameters
URL: https://github.com/apache/couchdb/pull/1110#discussion_r164162344
##########
File path: src/couch/src/couch_db.erl
##########
@@ -1738,14 +1738,26 @@ do_pipe([Filter|Rest], F0) ->
set_namespace_range(Options, undefined) -> Options;
set_namespace_range(Options, NS) ->
- %% FIXME depending on order we might need to swap keys
- SK = select_gt(
- proplists:get_value(start_key, Options, <<"">>),
- <<NS/binary, "/">>),
- EK = select_lt(
- proplists:get_value(end_key, Options, <<NS/binary, "0">>),
- <<NS/binary, "0">>),
- [{start_key, SK}, {end_key_gt, EK}].
+ SK0 = proplists:get_value(start_key, Options, <<NS/binary, "/">>),
+ EKType = case proplists:get_value(end_key_gt, Options) of
+ undefined -> end_key;
+ _ -> end_key_gt
+ end,
+ EK0 = case EKType of
+ end_key -> proplists:get_value(end_key, Options, <<NS/binary, "0">>);
+ end_key_gt ->
+ proplists:get_value(end_key_gt, Options, <<NS/binary, "0">>)
+ end,
+ case proplists:get_value(dir, Options, fwd) of
+ fwd ->
+ SK = select_gt(SK0, <<NS/binary, "/">>),
+ EK = select_lt(EK0, <<NS/binary, "0">>),
+ [{dir, fwd}, {start_key, SK}, {EKType, EK}];
Review comment:
Erm, I think this has gone backwards. The point is to not hard code these or
gate them based on the start and end keys. Just pull the dir value from Options
and pass it here and on line 1759.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services