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

Should raise an error when attempting to get a key holding a list #101

Closed
bluemoo opened this issue Dec 18, 2015 · 1 comment · Fixed by #166
Closed

Should raise an error when attempting to get a key holding a list #101

bluemoo opened this issue Dec 18, 2015 · 1 comment · Fixed by #166

Comments

@bluemoo
Copy link
Contributor

bluemoo commented Dec 18, 2015

Here's what happens when I try to use 'get' on a key that I've used to store a list:

>>> from redis_cache import get_redis_connection
>>> client = get_redis_connection('persistent')
>>> client.rpush('foo', 1)
1L
>>> client.get('foo')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/noah/envs/adioso/lib/python2.6/site-packages/redis/client.py", line 551, in get
    return self.execute_command('GET', name)
  File "/home/noah/envs/adioso/lib/python2.6/site-packages/redis/client.py", line 361, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/home/noah/envs/adioso/lib/python2.6/site-packages/redis/client.py", line 371, in parse_response
    response = connection.read_response()
  File "/home/noah/envs/adioso/lib/python2.6/site-packages/redis/connection.py", line 311, in read_response
    raise response
ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value

Using fakeredis, I don't get any error:

>>> import fakeredis
>>> client = fakeredis.FakeStrictRedis()
>>> client.rpush('foo', 1)
1
>>> client.get('foo')
"['1']"

I think the fix to this might involve tracking the type of item at each key, which could get involved. Is this of interest to fakeredis?

@bmerry
Copy link
Collaborator

bmerry commented Nov 9, 2017

I'm currently working on a more complete version of this, which will do type checks in all commands.

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

Successfully merging a pull request may close this issue.

3 participants