Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

use_index param in get_query_result and get_partitioned_query_result does not support list data #473

Closed
CodipherX opened this issue May 19, 2020 · 3 comments

Comments

@CodipherX
Copy link
Contributor

Please read these guidelines before opening an issue.

Bug Description

As per https://docs.couchdb.org/en/stable/api/database/find.html#db-find , use_index could be either as "<design_document>" or ["<design_document>", "<index_name>"]
However on putting a list in the use_index param, exception is thrown

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

  1. Non-partitioned DB
from cloudant import couchdb

with couchdb("admin", "admin", url="http://localhost:5984") as couchClient:
    selector = {'_id': {'$gt': 0}}
    db = couchClient["foo"]
    docs = db.get_query_result(selector,use_index=["ddoc","index"],raw_result=True)

  1. Partitioned DB
from cloudant import couchdb

with couchdb("admin", "admin", url="http://localhost:5984") as couchClient:
    selector = {'_id': {'$gt': 0}}
    db = couchClient["bar"]
    docs = db.get_partitioned_query_result("pkey",selector,use_index=["index","ddoc"],raw_result=True)

2. What you expected to happen

The query should run successfully

3. What actually happened

Exception is thrown CloudantArgumentError: Argument use_index is not an instance of expected type: <class 'str'>

Environment details

Cloudant : 2.13
Python: 3.7

@bessbd
Copy link
Contributor

bessbd commented May 19, 2020

Hi @CodipherX ,

The bug seems indeed valid:

'use_index': STRTYPE
defines use_index as STRTYPE instead of (STRTYPE, list).

Are you interested in opening a PR for this?

@CodipherX
Copy link
Contributor Author

Hi @bessbd ,
I will open a PR soon.

Thanks and regards

@ricellis
Copy link
Member

Our new cloudant-python-sdk(beta) has the array form of the API allowing for both a design document or a design document and an index to be specified in use_index.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants