couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From willhol...@apache.org
Subject [couchdb] branch master updated: Fix _explain for sort descending (#1025)
Date Tue, 28 Nov 2017 11:30:16 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


The following commit(s) were added to refs/heads/master by this push:
     new 27dcd6b  Fix _explain for sort descending (#1025)
27dcd6b is described below

commit 27dcd6b3eb85017d4103c89182fd11f82d1a7752
Author: Will Holley <willholley@gmail.com>
AuthorDate: Tue Nov 28 11:30:14 2017 +0000

    Fix _explain for sort descending (#1025)
    
    Handle the case when startkey and endkey
    are reversed. To create valid JSON we need to
    replace the internal representation of the startkey
    with a string.
    
    Fixes #1023
---
 src/mango/src/mango_cursor_view.erl       | 2 +-
 src/mango/test/05-index-selection-test.py | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/mango/src/mango_cursor_view.erl b/src/mango/src/mango_cursor_view.erl
index 3fcec07..7c57b14 100644
--- a/src/mango/src/mango_cursor_view.erl
+++ b/src/mango/src/mango_cursor_view.erl
@@ -66,7 +66,7 @@ explain(Cursor) ->
         {include_docs, Args#mrargs.include_docs},
         {view_type, Args#mrargs.view_type},
         {reduce, Args#mrargs.reduce},
-        {start_key, Args#mrargs.start_key},
+        {start_key, maybe_replace_max_json(Args#mrargs.start_key)},
         {end_key, maybe_replace_max_json(Args#mrargs.end_key)},
         {direction, Args#mrargs.direction},
         {stable, Args#mrargs.stable},
diff --git a/src/mango/test/05-index-selection-test.py b/src/mango/test/05-index-selection-test.py
index f8cc825..ef662a9 100644
--- a/src/mango/test/05-index-selection-test.py
+++ b/src/mango/test/05-index-selection-test.py
@@ -181,6 +181,14 @@ class IndexSelectionTests:
             self.db.save_doc(design_doc)
 
 
+    def test_explain_sort_reverse(self):
+        selector = {
+            "manager": {"$gt": None}
+        }
+        resp_explain = self.db.find(selector, fields=["manager"], sort=[{"manager":"desc"}],
explain=True)
+        self.assertEqual(resp_explain["index"]["type"], "json")
+        
+
 class JSONIndexSelectionTests(mango.UserDocsTests, IndexSelectionTests):
 
     @classmethod

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

Mime
View raw message