Skip to content

Commit

Permalink
Don't throw a TypeError slicing unsorted results, fixes #6 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyst authored and janwijbrand committed Jun 22, 2017
1 parent 76a2777 commit fbb0d96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions CHANGES.txt
Expand Up @@ -4,8 +4,7 @@ CHANGES
2.4 (unreleased)
----------------

- Nothing changed yet.

- Don't throw a TypeError slicing unsorted results, fixes #6

2.3 (2017-04-26)
----------------
Expand Down
3 changes: 2 additions & 1 deletion src/hurry/query/query.py
Expand Up @@ -286,8 +286,9 @@ def searchResults(
selected_results = reversed(selected_results)
is_iterator = True
if limit or start:
slice_end = limit and start + limit or None
selected_results = itertools.islice(
selected_results, start, start + limit)
selected_results, start, slice_end)
is_iterator = True

if is_iterator:
Expand Down
8 changes: 8 additions & 0 deletions src/hurry/query/query.txt
Expand Up @@ -546,6 +546,14 @@ the tested index is deterministic enough to be used as a proper test).
>>> displayResult(Eq(f1, 'a'), limit=2)
[1, 2]

>>> f1 = ('catalog1', 'f1')
>>> displayResult(Eq(f1, 'a'), start=1)
[2, 6]

>>> f1 = ('catalog1', 'f1')
>>> displayResult(Eq(f1, 'a'), start=1, limit=1)
[2]

>>> f1 = ('catalog1', 'f1')
>>> displayResult(Eq(f1, 'a'), limit=2, reverse=True)
[6, 2]
Expand Down

0 comments on commit fbb0d96

Please sign in to comment.