Skip to content

Commit

Permalink
Fix Cursor handling of lists (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
cariad authored Jul 21, 2023
1 parent e3016ef commit 64d357f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/package/cursor.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Cursor
=====
======

.. py:module:: rolumns
:noindex:
Expand Down
2 changes: 1 addition & 1 deletion rolumns/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __next__(self) -> Any:
if isinstance(self._current, list):
current_list = cast(Iterator[Any], self._current)
self._resolved = iter(current_list)
self._current = next(resolved)
self._current = next(self._resolved)

return self.current

Expand Down
20 changes: 20 additions & 0 deletions tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,25 @@ def test_group() -> None:
assert child.cursor_group == ByPath("value")


def test_list() -> None:
cursor = Cursor("value")

cursor.load(
{
"value": [
"one",
"two",
"three",
],
},
)

assert list(cursor) == [
"one",
"two",
"three",
]


def test_str() -> None:
assert str(Cursor("value")) == 'Cursor(ByPath("value"))'

0 comments on commit 64d357f

Please sign in to comment.