nickva commented on code in PR #4792:
URL: https://github.com/apache/couchdb/pull/4792#discussion_r1346517007
##########
src/mango/src/mango_cursor.erl:
##########
@@ -53,8 +53,24 @@ create(Db, Selector0, Opts, Kind) ->
{UsableIndexes, Trace} = mango_idx:get_usable_indexes(Db, Selector, Opts,
Kind),
case maybe_filter_indexes_by_ddoc(UsableIndexes, Opts) of
[] ->
- % use_index doesn't match a valid index - fall back to a valid one
- create_cursor(Db, {UsableIndexes, Trace}, Selector, Opts);
+ % use_index doesn't match a valid index - determine how
+ % this shall be handled by the further settings
+ case allow_fallback(Opts) of
+ true ->
+ % fall back to a valid index
+ create_cursor(Db, {UsableIndexes, Trace}, Selector, Opts);
+ false ->
+ % return an error
+ Details =
+ case use_index(Opts) of
+ [] ->
+ [];
+ UseIndex ->
+ [DesignId | Rest] = UseIndex,
+ [ddoc_name(DesignId) | Rest]
Review Comment:
Since in other parts like in the `MANGO_ERROR` macro, we explicitly only
handle `[]`, `[DDoc]`, `[DDoc, Index]` cases might as well be explicit here as
well and handle it as 3 cases too.
--
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]