summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2020-02-12 09:57:55 +0200
committerGarren Smith <garren.smith@gmail.com>2020-02-12 09:57:55 +0200
commitb276933c39604715d2d164205632ee46c01cac46 (patch)
tree88b7007241557cb504d5072fac6183605509caa2
parentcd1536474ff2beeea7347a823d72426ec4f6e47c (diff)
downloadcouchdb-fdb-all-docs-encoding.tar.gz
fixes from reviewfdb-all-docs-encoding
-rw-r--r--src/chttpd/src/chttpd_db.erl6
-rw-r--r--src/fabric/src/fabric2_util.erl16
-rw-r--r--test/elixir/test/all_docs_test.exs9
3 files changed, 15 insertions, 16 deletions
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index d10017c9e..2e3af2064 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -927,12 +927,12 @@ all_docs_view_opts(Args) ->
end,
StartKeyOpts = case StartKey of
undefined -> [];
- _ -> [{start_key, fabric2_util:all_docs_encode(StartKey)}]
+ _ -> [{start_key, fabric2_util:encode_all_doc_key(StartKey)}]
end,
EndKeyOpts = case {EndKey, Args#mrargs.inclusive_end} of
{undefined, _} -> [];
- {_, false} -> [{end_key_gt, fabric2_util:all_docs_encode(EndKey)}];
- {_, true} -> [{end_key, fabric2_util:all_docs_encode(EndKey)}]
+ {_, false} -> [{end_key_gt, fabric2_util:encode_all_doc_key(EndKey)}];
+ {_, true} -> [{end_key, fabric2_util:encode_all_doc_key(EndKey)}]
end,
[
{dir, Args#mrargs.direction},
diff --git a/src/fabric/src/fabric2_util.erl b/src/fabric/src/fabric2_util.erl
index 973d169cb..2a940659e 100644
--- a/src/fabric/src/fabric2_util.erl
+++ b/src/fabric/src/fabric2_util.erl
@@ -35,7 +35,7 @@
from_hex/1,
uuid/0,
- all_docs_encode/1
+ encode_all_doc_key/1
]).
@@ -239,10 +239,10 @@ uuid() ->
to_hex(crypto:strong_rand_bytes(16)).
-all_docs_encode(null) -> <<>>;
-all_docs_encode(true) -> <<>>;
-all_docs_encode(false) -> <<>>;
-all_docs_encode(N) when is_number(N) -> <<>>;
-all_docs_encode(B) when is_binary(B) -> B;
-all_docs_encode(L) when is_list(L) -> <<255>>;
-all_docs_encode({O}) when is_list(O) -> <<255>>.
+encode_all_doc_key(null) -> <<>>;
+encode_all_doc_key(true) -> <<>>;
+encode_all_doc_key(false) -> <<>>;
+encode_all_doc_key(N) when is_number(N) -> <<>>;
+encode_all_doc_key(B) when is_binary(B) -> B;
+encode_all_doc_key(L) when is_list(L) -> <<255>>;
+encode_all_doc_key({O}) when is_list(O) -> <<255>>.
diff --git a/test/elixir/test/all_docs_test.exs b/test/elixir/test/all_docs_test.exs
index 53f80ff08..e3bca0f35 100644
--- a/test/elixir/test/all_docs_test.exs
+++ b/test/elixir/test/all_docs_test.exs
@@ -41,9 +41,9 @@ defmodule AllDocsTest do
assert resp["total_rows"] == length(rows)
# Check _all_docs offset
- resp = Couch.get("/#{db_name}/_all_docs", query: %{:startkey => "\"2\""}).body
- assert resp["offset"] == :null
- assert Enum.at(resp["rows"], 0)["key"] == "2"
+ resp = Couch.get("/#{db_name}/_all_docs", query: %{:startkey => "\"2\""}).body
+ assert resp["offset"] == :null
+ assert Enum.at(resp["rows"], 0)["key"] == "2"
# Confirm that queries may assume raw collation
resp =
@@ -187,6 +187,7 @@ defmodule AllDocsTest do
@tag :with_db
test "all_docs ordering", context do
db_name = context[:db_name]
+
docs = [
%{:_id => "a"},
%{:_id => "m"},
@@ -213,10 +214,8 @@ defmodule AllDocsTest do
resp = Couch.get("/#{db_name}/_all_docs", query: %{:end_key => 0}).body
rows = resp["rows"]
assert length(rows) === 0
-
end
-
defp get_ids(resp) do
%{"rows" => rows} = resp
Enum.map(rows, fn row -> row["id"] end)