couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [couchdb] 18/25: More bug fixes
Date Tue, 23 Jul 2019 20:13:27 GMT
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch prototype/views
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 3c39ce548a9ae8e4ee3a55b554cb29223ec87530
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
AuthorDate: Tue Jul 23 11:29:26 2019 -0500

    More bug fixes
---
 src/couch_views/src/couch_views.erl           |  2 +-
 src/couch_views/src/couch_views_jobs.erl      |  5 +++++
 src/couch_views/src/couch_views_reader.erl    | 18 ++++++++++++------
 src/couch_views/test/couch_views_map_test.erl | 11 ++++++-----
 4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/couch_views/src/couch_views.erl b/src/couch_views/src/couch_views.erl
index e619a67..8c565a6 100644
--- a/src/couch_views/src/couch_views.erl
+++ b/src/couch_views/src/couch_views.erl
@@ -57,7 +57,7 @@ query(Db, DDoc, ViewName, Callback, Acc0, Args0) ->
 maybe_update_view(_Db, _Mrst, #mrargs{update = false}) ->
     ok;
 
-maybe_update_view(_Db, _Mrst, #mrargs{update = laze}) ->
+maybe_update_view(_Db, _Mrst, #mrargs{update = lazy}) ->
     ok;
 
 maybe_update_view(Db, Mrst, _Args) ->
diff --git a/src/couch_views/src/couch_views_jobs.erl b/src/couch_views/src/couch_views_jobs.erl
index 85264c6..15852a1 100644
--- a/src/couch_views/src/couch_views_jobs.erl
+++ b/src/couch_views/src/couch_views_jobs.erl
@@ -18,6 +18,11 @@
     build_view_async/2
 ]).
 
+-ifdef(TEST).
+-compile(export_all).
+-compile(nowarn_export_all).
+-endif.
+
 
 -include_lib("couch_mrview/include/couch_mrview.hrl").
 -include("couch_views.hrl").
diff --git a/src/couch_views/src/couch_views_reader.erl b/src/couch_views/src/couch_views_reader.erl
index 41a37eb..2deb9f6 100644
--- a/src/couch_views/src/couch_views_reader.erl
+++ b/src/couch_views/src/couch_views_reader.erl
@@ -135,20 +135,26 @@ mrargs_to_fdb_options(Args) ->
         couch_views_encoding:encode(EndKey0)
     end,
 
-    EndKeyOpts = case {EndKey1, EndKeyDocId} of
-        {undefined, _} ->
+    EndKeyOpts = case {EndKey1, EndKeyDocId, Direction} of
+        {undefined, _, _} ->
             [];
-        {EndKey1, <<255>>} when not InclusiveEnd ->
+        {EndKey1, <<>>, rev} when not InclusiveEnd ->
+            % When we iterate in reverse with
+            % inclusive_end=false we have to set the
+            % EndKeyDocId to <<255>> so that we don't
+            % include matching rows.
+            [{end_key_gt, {EndKey1, <<255>>}}];
+        {EndKey1, <<255>>, _} when not InclusiveEnd ->
             % When inclusive_end=false we need to
             % elide the default end_key_docid so as
             % to not sort past the docids with the
             % given end key.
             [{end_key_gt, {EndKey1}}];
-        {EndKey1, EndKeyDocId} when not InclusiveEnd ->
+        {EndKey1, EndKeyDocId, _} when not InclusiveEnd ->
             [{end_key_gt, {EndKey1, EndKeyDocId}}];
-        {EndKey1, EndKeyDocId} when InclusiveEnd ->
+        {EndKey1, EndKeyDocId, _} when InclusiveEnd ->
             [{end_key, {EndKey1, EndKeyDocId}}];
-        {EndKey1, EndKeyDocId} when InclusiveEnd ->
+        {EndKey1, EndKeyDocId, _} when InclusiveEnd ->
             [{end_key_gt, {EndKey1, EndKeyDocId}}]
     end,
 
diff --git a/src/couch_views/test/couch_views_map_test.erl b/src/couch_views/test/couch_views_map_test.erl
index ab3000e..c5db382 100644
--- a/src/couch_views/test/couch_views_map_test.erl
+++ b/src/couch_views/test/couch_views_map_test.erl
@@ -76,7 +76,7 @@ should_map() ->
 
 
 should_map_with_startkey() ->
-    Result = run_query(<<"baz">>, #{start_key => 4}, true),
+    Result = run_query(<<"baz">>, #{start_key => 4}),
     Expect = {ok, [
         {row, [{id, <<"4">>}, {key, 4}, {value, 4}]},
         {row, [{id, <<"5">>}, {key, 5}, {value, 5}]},
@@ -276,7 +276,7 @@ should_map_with_startkey_and_endkey_with_key_array() ->
     % expect rows 9-4
     ?assertEqual({ok, lists:reverse(Rows2)}, ResultRev2),
 
-    ResultRev2 = run_query(<<"boom">>, #{
+    ResultRev3 = run_query(<<"boom">>, #{
         start_key => [<<"9">>, 9],
         end_key => [<<"4">>, 4],
         direction => rev,
@@ -285,7 +285,7 @@ should_map_with_startkey_and_endkey_with_key_array() ->
 
     % Here, specifying [<<"4">>, 4] as the key will prevent
     % us from including that row which leaves rows 9-5
-    ?assertEqual({ok, lists:reverse(lists:nthtail(1, Rows2))}, ResultRev2).
+    ?assertEqual({ok, lists:reverse(lists:nthtail(1, Rows2))}, ResultRev3).
 
 
 
@@ -446,8 +446,9 @@ run_query(Idx, Args, DebugCluster) ->
     Docs = make_docs(10),
     fabric2_db:update_docs(Db, [DDoc | Docs]),
     if not DebugCluster -> ok; true ->
-        %% couch_views:query(Db, DDoc, Idx, fun default_cb/2, [], #{}),
-        %% fabric2_fdb:debug_cluster()
+        io:format(standard_error, "Database: ~s~n", [DbName]),
+        couch_views:query(Db, DDoc, Idx, fun default_cb/2, [], #{}),
+        fabric2_fdb:debug_cluster(),
         ok
     end,
     couch_views:query(Db, DDoc, Idx, fun default_cb/2, [], Args).


Mime
View raw message