-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change /{db}/_design/{ddoc}/_view/{viewname} semantics for views with defined reduces #1204
Comments
I also found this very confusing. I think because (at least for me) the vast majority of view usage is without a corresponding reduce, it's not something that you come across much, and it's a pretty radical change that is only passively documented in the query param list. I think it might be worth modifying the documentation to pull this effect[1] into a warning documentation block to highlight it, and include an explanation to get everyone on the same page. Something like:
[1] That all view queries automatically become reduce queries when you add a reduce |
This is a backwards-compatibility breaking change and can not be introduced easily. The earliest such a change can be considered is 3.0.0. |
@wohali Any opinion on the documentation update suggestions? |
I would say it's better to mention this in the gentle intro to views here. If I had to guess at a reason, it might be because views are CouchDB's implementation of MapReduce, which suggests if both are defined, you want both. I don't think it warrants a call-out box in the API reference section, we already say:
With the increasing focus on Mango (and reduce coming soon to Mango) it might be best to ensure the user interface for Mango does something friendly and compatible here. /cc @tonysun83 @nickva |
This isn't quite what I see at http://docs.couchdb.org/en/2.1.1/api/ddoc/views.html - definitely an improvement. |
Compare with http://docs.couchdb.org/en/latest/api/ddoc/views.html Looks like @flimzy is ahead of you: apache/couchdb-documentation@bdfa864 I'll leave this open as an enhancement request, and edit the title to match. |
I understand why this is confusing, but I don’t see this changing going forward. We are happy to break BC for good reason, but this doesn’t warrant one IMHO. |
Personally, I agree, and I expect most of the rest of the core developers would agree as well. We can always re-open this; going to close for now as wontfix. |
Expected Behavior
View queries should always default to responding with a map if no value for the
reduce
parameter is supplied.Current Behavior
http://couch-instance/db-name/_design/ddoc_name/_view/view_name
http://couch-instance/db-name/_design/ddoc_name/_view/view_name
http://couch-instance/db-name/_design/ddoc_name/_view/view_name?reduce=false
http://couch-instance/db-name/_design/ddoc_name/_view/view_name?reduce=false
http://couch-instance/db-name/_design/ddoc_name/_view/view_name?reduce=true
http://couch-instance/db-name/_design/ddoc_name/_view/view_name?reduce=true
IMO scenario number 2 is surprising and unhelpful.
Adding a reduce to an existing ddoc that is used in application code will break all existing calls to a view which do not define
reduce=false
. It's not possible to define a view which has a reduce function but not a map function, so the inverse does not apply.Possible Solution
Change the default for
reduce
tofalse
.This change would affect a lot of existing users, so would need to be well documented and coincide with a major release version.
A couple of alternatives to this change might be:
Instead of defaulting, reject view queries which do not specify the
reduce
parameterUpdate the docs at http://docs.couchdb.org/en/2.0.0/api/ddoc/views.html
Currently they read:
But might be clearer if they read:
ref pouchdb/pouchdb#7127
The text was updated successfully, but these errors were encountered: