You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2020/02/03 10:24:50 UTC

[couchdb] branch mango_warning_string created (now 9022f11)

This is an automated email from the ASF dual-hosted git repository.

willholley pushed a change to branch mango_warning_string
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 9022f11  Return mango warnings as a delimited string

This branch includes the following new commits:

     new 9022f11  Return mango warnings as a delimited string

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Return mango warnings as a delimited string

Posted by wi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch mango_warning_string
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9022f1133726d767a1f886e46b7f7edf3d44510a
Author: Will Holley <wi...@gmail.com>
AuthorDate: Mon Feb 3 10:19:59 2020 +0000

    Return mango warnings as a delimited string
    
    The CouchDB API defines the warning field returned by _find to be
    a string (and this is what Fauxton expects). 5d55e289 was missing
    a string conversion and returned the warning(s) as an array. This
    restores the intended behaviour.
---
 src/mango/src/mango_cursor.erl              | 2 +-
 src/mango/test/05-index-selection-test.py   | 8 ++++----
 src/mango/test/12-use-correct-index-test.py | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mango/src/mango_cursor.erl b/src/mango/src/mango_cursor.erl
index 29be494..b1cb414 100644
--- a/src/mango/src/mango_cursor.erl
+++ b/src/mango/src/mango_cursor.erl
@@ -133,7 +133,7 @@ maybe_add_warning(UserFun, #cursor{index = Index, opts = Opts}, Stats, UserAcc)
         [] ->
             UserAcc;
         _ ->
-            WarningStr = lists:join(<<"\n">>, Warnings),
+            WarningStr = iolist_to_binary(lists:join(<<"\n">>, Warnings)),
             Arg = {add_key, warning, WarningStr},
             {_Go, UserAcc1} = UserFun(Arg, UserAcc),
             UserAcc1
diff --git a/src/mango/test/05-index-selection-test.py b/src/mango/test/05-index-selection-test.py
index 271e361..2bc5a88 100644
--- a/src/mango/test/05-index-selection-test.py
+++ b/src/mango/test/05-index-selection-test.py
@@ -84,7 +84,7 @@ class IndexSelectionTests:
         ddocid = "_design/age"
         r = self.db.find({}, use_index=ddocid, return_raw=True)
         self.assertEqual(
-            r["warning"][0].lower(),
+            r["warning"].split('\n')[0].lower(),
             "{0} was not used because it does not contain a valid index for this query.".format(
                 ddocid
             ),
@@ -107,7 +107,7 @@ class IndexSelectionTests:
         selector = {"company": "Pharmex"}
         r = self.db.find(selector, use_index=ddocid, return_raw=True)
         self.assertEqual(
-            r["warning"][0].lower(),
+            r["warning"].split('\n')[0].lower(),
             "{0} was not used because it does not contain a valid index for this query.".format(
                 ddocid
             ),
@@ -124,7 +124,7 @@ class IndexSelectionTests:
 
         resp = self.db.find(selector, use_index=[ddocid, name], return_raw=True)
         self.assertEqual(
-            resp["warning"][0].lower(),
+            resp["warning"].split('\n')[0].lower(),
             "{0}, {1} was not used because it is not a valid index for this query.".format(
                 ddocid, name
             ),
@@ -162,7 +162,7 @@ class IndexSelectionTests:
             selector, sort=["foo", "bar"], use_index=ddocid_invalid, return_raw=True
         )
         self.assertEqual(
-            resp["warning"][0].lower(),
+            resp["warning"].split('\n')[0].lower(),
             "{0} was not used because it does not contain a valid index for this query.".format(
                 ddocid_invalid
             ),
diff --git a/src/mango/test/12-use-correct-index-test.py b/src/mango/test/12-use-correct-index-test.py
index 3a2f60a..b6fe434 100644
--- a/src/mango/test/12-use-correct-index-test.py
+++ b/src/mango/test/12-use-correct-index-test.py
@@ -93,7 +93,7 @@ class ChooseCorrectIndexForDocs(mango.DbPerClass):
         self.assertEqual(explain_resp["index"]["type"], "special")
         resp = self.db.find(selector, return_raw=True)
         self.assertEqual(
-            resp["warning"][0].lower(),
+            resp["warning"].split('\n')[0].lower(),
             "no matching index found, create an index to optimize query time.",
         )