fix: Redis#exists(key) returns Integer as the default behaviour #1030
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
redis-rb/lib/redis.rb
Lines 576 to 596 in c97360b
After reading the error message, I interpreted it as follows. (The text in parentheses is my own completion)
Redis#exists(key)
is supposed to return integer.Redis#exists?(key)
instead (if you want to return a boolean in version 4.3 or later).Redis.exists_returns_integer = true
if you want to use the "new" behaviour (for users of version 4.3 or earlier)However, in my environment using redis-rb 4.4, when
Redis.exists_returns_integer = nil
(default setting),Redis#exists(key)
returnsboolean
with the above error message. I suspect that this is a bug.When this message was added, the version was prior to 4.3 (4.2.1).
So it would have returned the previous behavior (boolean) when
Redis.exists_returns_integer = nil
orRedis.exists_returns_integer = false
.However, now (or later) it returns the previous behavior (boolean) only when
Redis.exists_returns_integer = false
, and not whenI think it should return
integer
ifRedis.exists_returns_integer = nil
(default) orRedis.exists_returns_integer = true
.Perhaps
Redis.exists_returns_boolean
will be more suitable and simpler for opt-in/opt-out applications.Actually, this is my first pull request, so I may have the wrong way to contribute!
Please let me know if I'm wrong.
Thank you!:blush: