Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@santiagopardal
Copy link
Contributor

When trying to find one element and sorting collection.find_one(filter, sort={"key", -1}) there is a problem inside _get_dataset because

assert list(reversed({"key": -1})) == ["key"]

or, with a different syntax:

assert next(reversed({"key": -1})) == "key"

So it fails to unpack the sort_direction.

This PR addresses that issue by checking if the sort argument is a dictionary, as it could also be a list of tuples (key, direction) and transforming that dictionary into dict_items so that they can be reversed in the same fashion, (key, direction).

@codecov
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.76%. Comparing base (67b6fa8) to head (83b2789).
Report is 6 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #897   +/-   ##
========================================
  Coverage    95.75%   95.76%           
========================================
  Files           35       35           
  Lines        10017    10027   +10     
========================================
+ Hits          9592     9602   +10     
  Misses         425      425           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mdomke mdomke merged commit 7fb082b into mongomock:develop Sep 11, 2024
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.

2 participants