Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F3A5D200D09 for ; Tue, 12 Sep 2017 14:53:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F26201609C9; Tue, 12 Sep 2017 12:53:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4D0721609C6 for ; Tue, 12 Sep 2017 14:53:10 +0200 (CEST) Received: (qmail 66135 invoked by uid 500); 12 Sep 2017 12:53:08 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 66126 invoked by uid 99); 12 Sep 2017 12:53:08 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Sep 2017 12:53:08 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 27A1E81261; Tue, 12 Sep 2017 12:53:05 +0000 (UTC) Date: Tue, 12 Sep 2017 12:53:07 +0000 To: "commits@couchdb.apache.org" Subject: [couchdb] 02/03: Return 400 when no index can fulfil a sort MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: willholley@apache.org Reply-To: "commits@couchdb.apache.org" In-Reply-To: <150522078518.18704.12664832123590197473@gitbox.apache.org> References: <150522078518.18704.12664832123590197473@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: couchdb X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 302126b75b124f4f00a8c9629b086c8b92d42784 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20170912125306.27A1E81261@gitbox.apache.org> archived-at: Tue, 12 Sep 2017 12:53:11 -0000 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 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" .