You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "jiahuili430 (via GitHub)" <gi...@apache.org> on 2023/04/11 21:36:27 UTC
[GitHub] [couchdb] jiahuili430 opened a new pull request, #4524: Querying `_all_docs` with non-string `key` should return an empty list
jiahuili430 opened a new pull request, #4524:
URL: https://github.com/apache/couchdb/pull/4524
<!-- Thank you for your contribution!
Please file this form by replacing the Markdown comments
with your text. If a section needs no action - remove it.
Also remember, that CouchDB uses the Review-Then-Commit (RTC) model
of code collaboration. Positive feedback is represented +1 from committers
and negative is a -1. The -1 also means veto, and needs to be addressed
to proceed. Once there are no objections, the PR can be merged by a
CouchDB committer.
See: http://couchdb.apache.org/bylaws.html#decisions for more info. -->
## Overview
<!-- Please give a short brief for the pull request,
what problem it solves or how it makes things better. -->
Querying `_all_docs` with a non-string `key` should return an empty list, but currently, it will return all documents. This PR should fix it.
## Testing recommendations
`make eunit apps=couch_mrview suites=couch_mrview_all_docs_tests`
<!-- Describe how we can test your changes.
Does it provide any behaviour that the end users
could notice? -->
## Related Issues or Pull Requests
fix https://github.com/apache/couchdb/issues/1479
<!-- If your changes affect multiple components in different
repositories please put links to those issues or pull requests here. -->
## Checklist
- [ ] Code is written and works correctly
- [ ] Changes are covered by tests
- [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
- [ ] Documentation changes were made in the `src/docs` folder
- [ ] Documentation changes were backported (separated PR) to affected branches
--
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: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb] nickva commented on a diff in pull request #4524: Querying `_all_docs` with non-string `key` should return an empty list
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #4524:
URL: https://github.com/apache/couchdb/pull/4524#discussion_r1164263998
##########
src/couch_mrview/test/eunit/couch_mrview_all_docs_tests.erl:
##########
@@ -92,8 +113,10 @@ should_query_with_range_and_same_keys(Db) ->
raise_error_query_with_range_and_different_keys(Db) ->
Error = {query_parse_error, <<"`keys` is incompatible with `key`, `start_key` and `end_key`">>},
- ?_assertThrow(Error, run_query(Db, [{keys, [<<"1">>]}, {start_key, <<"5">>}])),
- ?_assertThrow(Error, run_query(Db, [{keys, [<<"5">>]}, {start_key, <<"5">>}])).
+ [
+ ?_assertThrow(Error, run_query(Db, [{keys, [<<"1">>]}, {start_key, <<"5">>}])),
+ ?_assertThrow(Error, run_query(Db, [{keys, [<<"5">>]}, {start_key, <<"5">>}]))
+ ].
Review Comment:
Good catch!
--
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: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb] nickva merged pull request #4524: Querying `_all_docs` with non-string `key` should return an empty list
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva merged PR #4524:
URL: https://github.com/apache/couchdb/pull/4524
--
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: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb] nickva commented on a diff in pull request #4524: Querying `_all_docs` with non-string `key` should return an empty list
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #4524:
URL: https://github.com/apache/couchdb/pull/4524#discussion_r1164281995
##########
src/couch_mrview/src/couch_mrview_util.erl:
##########
@@ -903,12 +903,12 @@ all_docs_key_opts(#mrargs{keys = Keys, direction = Dir} = Args, Extra) ->
Keys
).
-ad_skey_opts(#mrargs{start_key = SKey}) when is_binary(SKey) ->
+ad_skey_opts(#mrargs{start_key = SKey}) when SKey =/= undefined ->
[{start_key, SKey}];
ad_skey_opts(#mrargs{start_key_docid = SKeyDocId}) ->
[{start_key, SKeyDocId}].
Review Comment:
We don't allow non-string document IDs. At first it would seem we should strongly validate here and allow only `binary|undefined` However, with start/end keys users may use lowest/highest values that are outside the range, something like `start_key=null`, `end_key=[{}]` or something similar and we wouldn't want to prevent them from doing it so this implementation would work well there.
--
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: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb] rnewson commented on a diff in pull request #4524: Querying `_all_docs` with non-string `key` should return an empty list
Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on code in PR #4524:
URL: https://github.com/apache/couchdb/pull/4524#discussion_r1164304016
##########
src/couch_mrview/src/couch_mrview_util.erl:
##########
@@ -903,12 +903,12 @@ all_docs_key_opts(#mrargs{keys = Keys, direction = Dir} = Args, Extra) ->
Keys
).
-ad_skey_opts(#mrargs{start_key = SKey}) when is_binary(SKey) ->
+ad_skey_opts(#mrargs{start_key = SKey}) when SKey =/= undefined ->
[{start_key, SKey}];
ad_skey_opts(#mrargs{start_key_docid = SKeyDocId}) ->
[{start_key, SKeyDocId}].
Review Comment:
agreed.
--
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: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org