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

Add type checking #166

Merged
merged 5 commits into from
Mar 22, 2018
Merged

Add type checking #166

merged 5 commits into from
Mar 22, 2018

Conversation

bmerry
Copy link
Collaborator

@bmerry bmerry commented Nov 9, 2017

This extends all the commands that operate on existing data of a specific type to raise a redis.ResponseError if the key exists but is not of that type. This fixes #101, but is far more general than #136.

The stricter checking exposed some bugs, so this PR also contains fixes (with unit tests) for #163, #164, #165.

@bmerry
Copy link
Collaborator Author

bmerry commented Nov 9, 2017

@jamesls I know there is a backlog of PRs, but it would be great if this could be looked at before too much other code gets changed: it touches the majority of the functions in the API and so will be nightmare to merge if it diverges too far from master.

@bmerry
Copy link
Collaborator Author

bmerry commented Nov 10, 2017

One area that isn't covered is distinguishing sets and hyperloglogs. That would take quite a bit more work, because the hyperloglog functions are mapped to set functions.

Any operation that queries or mutates a ZSET will raise an appropriate
redis.ResponseError if the key is already present with a different type.
New tests are included to test this. ZINTERSTORE and ZUNIONSTORE have
special treatment to allow SET types as well (undocumented feature of
redis).

The goal is to later extend this to other types as well.
This extends the previous commit to also raise a ResponseError when
running a set operation on a non-set.
This also fixes a bug in `decr`: it would set the internal value to
the integer value, without wrapping it in to_bytes.
Also fixed up the linsert implementation (with tests). It only handled
"before", not "after", and it did not handle the case where the pivot is
missing.

The brpoplpush implementation was simplified to just call rpoplpush,
since the implementations were identical.
Also fixed a bug where HINCRBY and HINCRBYFLOAT wrote the integer/float
value back into the Python dict rather than the string form.
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.

Should raise an error when attempting to get a key holding a list
1 participant