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

__delitem__ missing #223

Closed
viljoviitanen opened this issue Nov 8, 2018 · 1 comment
Closed

__delitem__ missing #223

viljoviitanen opened this issue Nov 8, 2018 · 1 comment

Comments

@viljoviitanen
Copy link
Contributor

Noticed fakeredis does not support "del" operator, i.e. it does not implement __delitem__ , while real redis does.

So code like this works on real redis:

import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
r['foo'] = 'bar'
print (r['foo'])  #bar
del r['foo']
print (r['foo'])  #KeyError: 'foo'

but fails on fakeredis:

import fakeredis
r = fakeredis.FakeStrictRedis()
r['foo'] = 'bar'
print (r['foo'])  #bar
del r['foo']      #AttributeError: __delitem__
#r.delete('foo')  #this would work

My guess on this is that even if __delitem__ is there in _StrKeyDict, because of name mangling, this happens.

If there's interest in getting this fixed, I can probably do a clean enough PR.

@bmerry
Copy link
Collaborator

bmerry commented Nov 8, 2018

If there's interest in getting this fixed, I can probably do a clean enough PR.

Yes, PRs are very welcome. I'm guessing it should be a pretty thin wrapper around .delete.

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