Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

In a view multi-query request, set view type for each query #133

Closed
wants to merge 1 commit into from

Conversation

nickva
Copy link
Contributor

@nickva nickva commented Jul 21, 2016

View type can be overridden if user explicitly sets reduce=false, for example.
This can happen for individual query.

Previously this didn't happen and view_type was set once at the top, just
based on the view itself. For for example, a query like this:

{
  "queries": [{
    "include_docs": true,
    "reduce": false
  }]
}

would fail with:

{"error":"query_parse_error","reason":"`include_docs` is invalid for reduce"}

But it shouldn't fail because user explicitly disabled reduce for that one.

To fix, make sure to call set_view_type for each query's args.

Jira: COUCHDB-3070

@kxepal
Copy link
Member

kxepal commented Jul 22, 2016

+1

Namely, a default `reduce` view type can be overridden to behave like a `map`,
if user explicitly sets `reduce=false`.

Previously this didn't happen. For example, a query like this:

```
{
  "queries": [{
    "include_docs": true,
    "reduce": false
  }]
}
```

 would fail with:

```
{"error":"query_parse_error","reason":"`include_docs` is invalid for reduce"}
```

 but it shouldn't, because user explicitly disabled `reduce` and now
`include_docs` is valid for a map view.

To fix, make sure to call `set_view_type` for each query's args.

Jira: COUCHDB-3070
@asfgit asfgit force-pushed the couchdb-3070-fix-multi-query-view-type branch from 12af169 to cca0df5 Compare July 22, 2016 07:36
@nickva
Copy link
Contributor Author

nickva commented Jul 22, 2016

Updated pr with 2 tests. One checks when default query type is not overridden then include_docs=true should throw a validation exception. Other checks if user explicitly sets reduce=false and then query should succeed.

@iilyak
Copy link
Contributor

iilyak commented Jul 22, 2016

+1

    Running test function(s):
      chttpd_view:check_multi_query_reduce_view_overrides_test_/0
======================== EUnit ========================
chttpd_view:103: t_check_include_docs_throw_validation_error...[0.019 s] ok
chttpd_view:112: t_check_user_can_override_individual_query_type...[0.008 s] ok
=======================================================
  2 tests passed.

@nickva nickva closed this Jul 22, 2016
@asfgit asfgit deleted the couchdb-3070-fix-multi-query-view-type branch July 25, 2016 17:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants