mikerhodes commented on code in PR #4394:
URL: https://github.com/apache/couchdb/pull/4394#discussion_r1081539012
##########
src/mango/src/mango_cursor_view.erl:
##########
@@ -248,6 +266,19 @@ view_cb({row, Row}, #mrargs{extra = Options} = Acc) ->
key = couch_util:get_value(key, Row),
doc = couch_util:get_value(doc, Row)
},
+ % This supports receiving our "arguments" either as just the `selector`
+ % or in the new record in `callback_args`. This is to support mid-upgrade
+ % clusters where the non-upgraded coordinator nodes will send the older
style.
+ % TODO remove this in a couple of couchdb versions.
+ {Selector, Fields} =
+ case couch_util:get_value(callback_args, Options) of
+ % old style
+ undefined ->
+ {couch_util:get_value(selector, Options), undefined};
+ % new style - assume a viewcbargs
+ Args ->
Review Comment:
I wanted to avoid exposing the "internals" of the viewcbargs here. I found
you couldn't use your own function in a guard only a BIF, ie, I tried `when
is_viewcbargs(Args)`. In the end, perhaps you're right that it's better to leak
the Map implementation such that there is a decent guard on the `case`
statement -- what do you think, I'm not sure what works well in Erlang here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]