tonysun83 commented on a change in pull request #962: Mango: generate a warning
instead of an error when an user-specified index cannot be used
URL: https://github.com/apache/couchdb/pull/962#discussion_r153707667
##########
File path: src/mango/src/mango_cursor.erl
##########
@@ -150,12 +151,54 @@ group_indexes_by_type(Indexes) ->
end, ?CURSOR_MODULES).
-maybe_add_warning(UserFun, #idx{type = IndexType}, UserAcc) ->
- case IndexType of
+maybe_add_warning(UserFun, #cursor{index = Index, opts = Opts}, UserAcc) ->
+ UseIndexInvalid = case lists:keyfind(use_index, 1, Opts) of
+ {use_index, []} ->
+ [];
+ {use_index, [DesignId]} ->
+ case filter_indexes([Index], DesignId) of
+ [] ->
+ [fmt("_design/~s was not used because it does not contain
a valid index for this query.",
+ [ddoc_name(DesignId)])];
+ _ ->
+ []
+ end;
+ {use_index, [DesignId, ViewName]} ->
+ case filter_indexes([Index], DesignId, ViewName) of
+ [] ->
+ [fmt("_design/~s, ~s was not used because it is not a
valid index for this query.",
+ [ddoc_name(DesignId), ViewName])];
Review comment:
same as the above comment
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services