Skip to content

Add to_list() to Cursor and CommandCursor - #958

Open
DanShinde wants to merge 1 commit into
mongomock:developfrom
DanShinde:fix/cursor-to-list
Open

DanShinde wants to merge 1 commit into
mongomock:developfrom
DanShinde:fix/cursor-to-list

Conversation

@DanShinde

Copy link
Copy Markdown

pymongo 4.9 added Cursor.to_list() and CommandCursor.to_list(), so code like collection.aggregate(...).to_list() raised AttributeError under mongomock. Both cursors now support to_list(length=None), reading at most length remaining documents and rejecting a length below 1 with ValueError, as pymongo does.

Fixes #924

pymongo 4.9 added Cursor.to_list() and CommandCursor.to_list(), so code
like collection.aggregate(...).to_list() raised AttributeError under
mongomock. Both cursors now support to_list(length=None), reading at
most `length` remaining documents and rejecting a length below 1 with
ValueError, as pymongo does.

Fixes mongomock#924
@DanShinde

Copy link
Copy Markdown
Author

Note on the failing checks: both failures come from develop, not from this change.

  • test (3.9): Hatch now installs coverage>=7.11, which requires Python 3.10+, so the 3.9 job fails while installing dependencies. The other test jobs are then cancelled by fail-fast. Fix CI against current test dependencies #951 pins the test dependencies and fixes this.
  • Build & verify package: the current hatchling writes Metadata-Version: 2.5, and the older twine bundled in hynek/build-and-inspect-python-package@v2 rejects it. A clean build of develop produces the same 2.5 metadata (it passes twine check with twine 7), so bumping that action or pinning hatchling should fix it.

Locally, hatch fmt --check passes, and so does hatch test on Python 3.10–3.13 with pymongo 3, pymongo 4 and no pymongo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'CommandCursor' object has no attribute 'to_list'

1 participant