diff options
author | Will Holley <willholley@gmail.com> | 2020-02-03 10:19:59 +0000 |
---|---|---|
committer | Will Holley <willholley@gmail.com> | 2020-02-03 11:05:21 +0000 |
commit | a19b9ff23ddb7da217954f963009d38c630891a7 (patch) | |
tree | 82db898307d5c4680e7cae272c2c4e53b2981139 /src/mango | |
parent | b9d138b0a058fabd5943511e9951e2fbe50a4fd2 (diff) | |
download | couchdb-a19b9ff23ddb7da217954f963009d38c630891a7.tar.gz |
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.
Diffstat (limited to 'src/mango')
-rw-r--r-- | src/mango/src/mango_cursor.erl | 2 | ||||
-rw-r--r-- | src/mango/test/05-index-selection-test.py | 8 | ||||
-rw-r--r-- | 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 29be49490..b1cb4148e 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 271e36176..2bc5a88f0 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 3a2f60af8..b6fe434f8 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.", ) |