Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/docs/src/api/database/find.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,9 @@ it easier to take advantage of future improvements to query planning
:>json object mrargs: Arguments passed to the underlying view.
:>json number limit: Limit parameter used.
:>json number skip: Skip parameter used.
:>json array fields: Fields to be returned by the query.
:>json array fields: Fields to be returned by the query. The `[]`
value here means all the fields, since there is no projection
happening in that case.
:>json boolean partitioned: The database is partitioned or not.
:>json array index_candidates: The list of all indexes that were
found but not selected for serving the query. See :ref:`the
Expand Down
16 changes: 10 additions & 6 deletions src/mango/src/mango_cursor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ extract_selector_hints(Selector) ->
| {opts, ejson()}
| {limit, integer()}
| {skip, integer()}
| {fields, fields()}
| {fields, [field()]}
| {index_candidates, [candidate_index()]}
| {selector_hints, selector_hints()}
| {atom(), any()}.
Expand All @@ -309,7 +309,7 @@ explain(#cursor{} = Cursor) ->
opts = Opts0,
limit = Limit,
skip = Skip,
fields = Fields
fields = Fields0
} = Cursor,
DbName = couch_db:name(Db),
Partitioned = fabric_util:is_partitioned(Db),
Expand All @@ -332,6 +332,11 @@ explain(#cursor{} = Cursor) ->
false ->
Opts1
end,
Fields =
case Fields0 of
all_fields -> [];
Value -> Value
end,
CandidateIndexes = extract_candidate_indexes(Cursor),
SelectorHints = extract_selector_hints(Selector),
{
Expand Down Expand Up @@ -1091,7 +1096,6 @@ explain_test_() ->
t_explain_empty(_) ->
Selector = {[]},
Indexes = sets:new(),
Fields = all_fields,
Trace =
#{
all_indexes => Indexes,
Expand All @@ -1110,7 +1114,7 @@ t_explain_empty(_) ->
opts = [{user_ctx, user_ctx}],
limit = limit,
skip = skip,
fields = Fields,
fields = all_fields,
trace = Trace
},
Hints = [{[{type, json}, {indexable_fields, []}, {unindexable_fields, []}]}],
Expand All @@ -1123,7 +1127,7 @@ t_explain_empty(_) ->
{opts, {[]}},
{limit, limit},
{skip, skip},
{fields, Fields},
{fields, []},
{index_candidates, []},
{selector_hints, Hints}
]},
Expand All @@ -1140,7 +1144,7 @@ t_explain_regular(_) ->
},
Selector = {[]},
Indexes = sets:from_list([Index]),
Fields = all_fields,
Fields = some_fields,
Trace =
#{
all_indexes => Indexes,
Expand Down