-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Redis operation that returns dict now converted to Lua table when called inside eval operation #209
Redis operation that returns dict now converted to Lua table when called inside eval operation #209
Conversation
…ries are now passed as lua tables instead of python lists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. For consistency with the other tests, can you pass the key being accessed to redis.eval?
…o keep consistency with other tests
@bmerry I added the key as you asked. but for future reference please notice that as far as I've seen the tests never use the keys that are passed to them but using hard-coded values within the Lua scripts. |
test_fakeredis.py
Outdated
end | ||
return result | ||
""" | ||
val = self.redis.eval(lua, 0, 'foo') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 1, not 0 (number of keys passed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are totally right.
Fixed it.
I agree, that's not ideal, but it's legal. According to the redis docs, "All Redis commands must be analyzed before execution to determine which keys the command will operate on. In order for this to be true for EVAL, keys must be passed explicitly." It doesn't matter to redis whether the Lua code uses KEYS or hard-codes them, as long as the redis server is informed about all keys that might be accessed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I'm going to merge it now.
During eval operation, results of Redis operations returning dictionaries are now passed as Lua tables instead of python lists
This allows for iteration over them within the Lua script.
This is a fix to the error described in issue 204