couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From willhol...@apache.org
Subject [couchdb] 02/03: Return 400 when no index can fulfil a sort
Date Tue, 12 Sep 2017 12:53:07 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 302126b75b124f4f00a8c9629b086c8b92d42784
Author: Will Holley <willholley@gmail.com>
AuthorDate: Mon Sep 11 17:13:00 2017 +0100

    Return 400 when no index can fulfil a sort
    
    Fixes a regression where a 500 status code was returned when
    no index is available to service a _find query because the
    sort order does not match any available indexes.
---
 src/mango/src/mango_error.erl             | 6 +++---
 src/mango/test/05-index-selection-test.py | 8 ++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/mango/src/mango_error.erl b/src/mango/src/mango_error.erl
index 3610165..4f8ae20 100644
--- a/src/mango/src/mango_error.erl
+++ b/src/mango/src/mango_error.erl
@@ -21,19 +21,19 @@
 ]).
 
 
-info(mango_cursor, {no_usable_index, no_indexes_defined}) ->
+info(mango_idx, {no_usable_index, no_indexes_defined}) ->
     {
         400,
         <<"no_usable_index">>,
         <<"There are no indexes defined in this database.">>
     };
-info(mango_cursor, {no_usable_index, no_index_matching_name}) ->
+info(mango_idx, {no_usable_index, no_index_matching_name}) ->
     {
         400,
         <<"no_usable_index">>,
         <<"No index matches the index specified with \"use_index\"">>
     };
-info(mango_cursor, {no_usable_index, missing_sort_index}) ->
+info(mango_idx, {no_usable_index, missing_sort_index}) ->
     {
         400,
         <<"no_usable_index">>,
diff --git a/src/mango/test/05-index-selection-test.py b/src/mango/test/05-index-selection-test.py
index a78c12f..2fb0a40 100644
--- a/src/mango/test/05-index-selection-test.py
+++ b/src/mango/test/05-index-selection-test.py
@@ -74,6 +74,14 @@ class IndexSelectionTests(mango.UserDocsTests):
             }, use_index=ddocid, explain=True)
         self.assertEqual(resp["index"]["ddoc"], ddocid)
 
+    def test_no_valid_sort_index(self):
+        try:
+            self.db.find({"_id": {"$gt": None}}, sort=["name"], return_raw=True)
+        except Exception, e:
+            self.assertEqual(e.response.status_code, 400)
+        else:
+            raise AssertionError("bad find")
+
     def test_invalid_use_index(self):
         # ddoc id for the age index
         ddocid = "_design/ad3d537c03cd7c6a43cf8dff66ef70ea54c2b40f"

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <commits@couchdb.apache.org>.

Mime
View raw message