This is an automated email from the ASF dual-hosted git repository. garren pushed a commit to branch fix-reverse-fold-options in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 5fdb528e80c0e5dad82464316f41e25798a7e27a Author: Garren Smith <[email protected]> AuthorDate: Mon Mar 9 16:10:24 2020 +0200 Fix bug in reverse folding with startkey_docid Fixes an issue where the first k/v was skipped if the startkey_docid was included. --- src/fabric/src/fabric2_fdb.erl | 3 +++ test/elixir/test/map_test.exs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl index c34b33c..b4a4fd6 100644 --- a/src/fabric/src/fabric2_fdb.erl +++ b/src/fabric/src/fabric2_fdb.erl @@ -1470,6 +1470,9 @@ get_fold_acc(Db, RangePrefix, UserCallback, UserAcc, Options) EndKey2 = case EndKey1 of undefined -> <<RangePrefix/binary, 16#FF>>; + EK2 when Reverse -> + PackedEK = erlfdb_tuple:pack({EK2}, RangePrefix), + <<PackedEK/binary, 16#FF>>; EK2 -> erlfdb_tuple:pack({EK2}, RangePrefix) end, diff --git a/test/elixir/test/map_test.exs b/test/elixir/test/map_test.exs index bccd417..a0a7d8b 100644 --- a/test/elixir/test/map_test.exs +++ b/test/elixir/test/map_test.exs @@ -535,6 +535,17 @@ defmodule ViewMapTest do assert error == "foundationdb_error" end + test "descending=true query with startkey_docid", context do + db_name = context[:db_name] + + url = "/#{db_name}/_design/map/_view/some" + resp = Couch.get(url, query: %{descending: true, startkey: 8, startkey_docid: "doc-id-8", limit: 3}) + ids = get_ids(resp) + + assert resp.status_code == 200 + assert ids == ["doc-id-8", "doc-id-7", "doc-id-6"] + end + def update_doc_value(db_name, id, value) do resp = Couch.get("/#{db_name}/#{id}") doc = convert(resp.body)
