You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benoit Chesneau <bc...@gmail.com> on 2014/02/07 12:05:12 UTC

Re: couchdb commit: updated refs/heads/key-vs-keys to a478b45

On Fri, Feb 7, 2014 at 12:00 PM,  <rn...@apache.org> wrote:
> Updated Branches:
>   refs/heads/key-vs-keys [created] a478b4549
>
>
> Send better error if user specifies key and keys
>
>
> Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
> Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a478b454
> Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a478b454
> Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a478b454
>
> Branch: refs/heads/key-vs-keys
> Commit: a478b4549289810f94332276e1f7fe75d4155212
> Parents: e7fdc16
> Author: Robert Newson <rn...@apache.org>
> Authored: Fri Feb 7 11:00:24 2014 +0000
> Committer: Robert Newson <rn...@apache.org>
> Committed: Fri Feb 7 11:00:24 2014 +0000
>
> ----------------------------------------------------------------------
>  src/couch_mrview/include/couch_mrview.hrl  | 1 +
>  src/couch_mrview/src/couch_mrview_http.erl | 2 +-
>  src/couch_mrview/src/couch_mrview_util.erl | 7 +++++++
>  3 files changed, 9 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/a478b454/src/couch_mrview/include/couch_mrview.hrl
> ----------------------------------------------------------------------
> diff --git a/src/couch_mrview/include/couch_mrview.hrl b/src/couch_mrview/include/couch_mrview.hrl
> index e4ec66d..cec3e31 100644
> --- a/src/couch_mrview/include/couch_mrview.hrl
> +++ b/src/couch_mrview/include/couch_mrview.hrl
> @@ -63,6 +63,7 @@
>      start_key_docid,
>      end_key,
>      end_key_docid,
> +    key,
>      keys,
>
>      direction = fwd,
>
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/a478b454/src/couch_mrview/src/couch_mrview_http.erl
> ----------------------------------------------------------------------
> diff --git a/src/couch_mrview/src/couch_mrview_http.erl b/src/couch_mrview/src/couch_mrview_http.erl
> index 7b92034..2f301a0 100644
> --- a/src/couch_mrview/src/couch_mrview_http.erl
> +++ b/src/couch_mrview/src/couch_mrview_http.erl
> @@ -301,7 +301,7 @@ parse_qs(Key, Val, Args) ->
>              Args#mrargs{reduce=parse_boolean(Val)};
>          "key" ->
>              JsonKey = ?JSON_DECODE(Val),
> -            Args#mrargs{start_key=JsonKey, end_key=JsonKey};
> +            Args#mrargs{key=JsonKey, start_key=JsonKey, end_key=JsonKey};
>          "keys" ->
>              Args#mrargs{keys=?JSON_DECODE(Val)};
>          "startkey" ->
>
> http://git-wip-us.apache.org/repos/asf/couchdb/blob/a478b454/src/couch_mrview/src/couch_mrview_util.erl
> ----------------------------------------------------------------------
> diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
> index c4272f8..7860b3b 100644
> --- a/src/couch_mrview/src/couch_mrview_util.erl
> +++ b/src/couch_mrview/src/couch_mrview_util.erl
> @@ -359,6 +359,13 @@ validate_args(Args) ->
>          _ -> mrverror(<<"`keys` must be an array of strings.">>)
>      end,
>
> +    case {Args#mrargs.keys, Args#mrargs.key} of
> +        {undefined, _} -> ok;
> +        {[], _} -> ok;
> +        {[_|_], undefined} -> ok;
> +        _ -> mrverror(<<"`key` is incompatible with `keys`">>)
> +    end,
> +
>      case {Args#mrargs.keys, Args#mrargs.start_key} of
>          {undefined, _} -> ok;
>          {[], _} -> ok;
>


hrm, but then we are testing key and if it pass doing the same test
for start_key, a bit redudant imo. What about adding a more generic
message on the start_key message saying keys is incompatible with
start_key or key?

- benoit