Skip to content

FIX start_key and end_key usage #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion couchdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ def _encode_view_options(options):
"""
retval = {}
for name, value in options.items():
if name in ('key', 'startkey', 'endkey') \
if name in ('key', 'startkey', 'endkey', 'start_key', 'end_key') \
or not isinstance(value, util.strbase):
value = json.encode(value)
retval[name] = value
Expand Down
8 changes: 7 additions & 1 deletion couchdb/tests/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,13 @@ def test_startkey(self):
[self.docfromnum(x) for x in range(self.num_docs - 2, self.num_docs)])
self.assertEqual([self.docfromrow(doc) for doc in self.db.iterview('test/nums', 10, startkey=1, descending=True)],
[self.docfromnum(x) for x in range(3, -1, -1)])


def test_start_key(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just start_key. The end_key case is still uncovered.

self.assertEqual([self.docfromrow(doc) for doc in self.db.iterview('test/nums', 10, start_key=int(self.num_docs / 2) - 1)],
[self.docfromnum(x) for x in range(self.num_docs - 2, self.num_docs)])
self.assertEqual([self.docfromrow(doc) for doc in self.db.iterview('test/nums', 10, start_key=1, descending=True)],
[self.docfromnum(x) for x in range(3, -1, -1)])

def test_nullkeys(self):
self.assertEqual(len(list(self.db.iterview('test/nulls', 10))), self.num_docs)

Expand Down