Skip to content
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

Current version of Collection on pypi throws exception if one checks if a document exists #119

Closed
larsborn opened this issue Sep 23, 2018 · 1 comment

Comments

@larsborn
Copy link
Contributor

Mainly putting this in here if someone is running into similar issues.

The collection objects on version 1.3.1 (most recent version pf pypi by the time of writing) throws a KeyError exception when one checks for document existence:

if my_key in db['my_collection']:
    [...]

Intended behavior would imho be to gracefully return False if the document does not exist. This behavior seems to be already implemented in the more recent version 1.3.2. through a new __contains__ method on the Collection class. Resolving #105 would solve this issue.

A current workaround obviously is:

exists = True
try:
    my_key in db['my_collection']
except KeyError:
    exists: False
if exists:
    [...]

Potentially related #113.

@tariqdaouda
Copy link
Collaborator

Yes is has been implemented in the 1.3.2 but only with the document key. I could improve it to also work with the document itself.

Cheers!

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

No branches or pull requests

2 participants