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

Creating a Design Doc with partitioned = false still creates design doc with partitioned enabled #466

Closed
CodipherX opened this issue May 6, 2020 · 4 comments · Fixed by #467
Assignees
Labels

Comments

@CodipherX
Copy link
Contributor

CodipherX commented May 6, 2020

Please read these guidelines before opening an issue.

Bug Description

I created a design document with following params:
ddoc = DesignDocument(db,"doc_id",partitioned=False)
However cloudant still created design doc with partitioned enabled in CouchDB

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

Create a design doc with following conf:
ddoc = DesignDocument(db,"doc_id",partitioned=False)
ddoc.add_view(ddoc_name,mapper)
ddoc.save()

2. What you expected to happen

The design doc should get created with partition disabled

3. What actually happened

The design doc gets created with partition enabled

Environment details

Cloudant Version: 2.13.0
CouchDB: 3.0.0

4. Workaround

I found the possible cause of the issue in src/cloudant/design_document.py
In the init function, the setdefault is given only for partitioned=True. I added the options for else condition as well
if partitioned:
self.setdefault('options', {'partitioned': True})
else:
self.setdefault('options', {'partitioned': False})

it solved my issue.

@CodipherX CodipherX changed the title CouchDB 3.0.0 Creating a Design Doc with partitioned = false still creates design doc with partitioned enabled May 6, 2020
@emlaver
Copy link
Member

emlaver commented May 6, 2020

Hi @CodipherX, I'm not witnessing this issue when I try to create a design document in either a non-partitioned or a partitioned database.
I also tried creating the design doc with and without the partitioned=False parameter and the response was what you'd expect to happen.
Environment:
Python: 3.7
python-cloudant: 2.13.0
Tried on both CouchDB 3.0.0 and Cloudant

@CodipherX
Copy link
Contributor Author

Hi @emlaver , I tried doing a dummy experiment again and got the same issue. The steps I followed are:

  1. Create a partitioned database foo in CouchDB
  2. Ran the following script:
from cloudant import couchdb
from cloudant.design_document import DesignDocument

with couchdb('admin', 'admin', url='http://localhost:5984') as couchClient:
    
    db = couchClient['foo']
    ddoc = DesignDocument(db,'view',partitioned=False)
    ddoc.add_view('myview','function(doc) { emit(doc.foo, doc.bar); }')
    ddoc.save()
  1. Checked the design doc info in the couchDB and got the following:
{
  "_id": "_design/view",
  "_rev": "1-c091b1c6dc79f702f339189348a97b99",
  "views": {
    "myview": {
      "map": "function(doc) { emit(doc.foo, doc.bar); }"
    }
  }
}

The partition is coming as enabled as can be seen below:
fauxton

However when I add the else clause as described in Workaround, I get the following info:

{
  "_id": "_design/view",
  "_rev": "5-884789917bd23ac2046aaf71d82efad9",
  "options": {
    "partitioned": false
  },
  "views": {
    "myview": {
      "map": "function(doc) { emit(doc.foo, doc.bar); }"
    }
  }
}

and the partition button is disabled
fauxton2

@emlaver
Copy link
Member

emlaver commented May 7, 2020

@CodipherX I can confirm that I'm seeing this issue as well. Would you like to open up a PR with your fix?

@emlaver emlaver self-assigned this May 7, 2020
@emlaver emlaver added the bug label May 7, 2020
@CodipherX
Copy link
Contributor Author

@emlaver Sure. I will open a PR soon.
Thanks

emlaver pushed a commit that referenced this issue May 8, 2020
)

Set default value for 'partitioned' parameter to false when creating a design document.
Co-authored-by: dipjyoti bisharad <[email protected]>
#466
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants