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

r.keys should retrurn an array #39

Closed
skaes opened this issue May 29, 2010 · 10 comments
Closed

r.keys should retrurn an array #39

skaes opened this issue May 29, 2010 · 10 comments

Comments

@skaes
Copy link
Contributor

skaes commented May 29, 2010

prior to 2.0, r.keys(pattern) returned the matching keys as an array. now it returns a single, blank separated string.

This new behavior breaks our beetle gem. We could work around it, but I consider this as a bug, as keys with embedded blanks seem to be supported by redis.

@antirez
Copy link
Contributor

antirez commented May 29, 2010

The server changed return type, I fixed that in 1.x branch and Ezra merged. I guess that with 2.0 this was re-inserted. My fault as I did not wrote regression tests in my patch.

@skaes
Copy link
Contributor Author

skaes commented May 29, 2010

I used redis-rb 2.0.0 against redis 1.2.6.

@soveran
Copy link
Collaborator

soveran commented May 29, 2010

Fixed in 2.0.1.

@skaes
Copy link
Contributor Author

skaes commented May 29, 2010

unfortunately, it's not fixed:

require 'rubygems'
require 'redis'
r = Redis.new
r.set("a b c", "x")  # ==> "OK"
r.get("a b c")       # ==> "x"
r.keys("*")          # ==> ["a", "b", "c"]

I think this should be ["a b c"], right?

@soveran
Copy link
Collaborator

soveran commented May 29, 2010

Even if a key with spaces works for all operations, I think it will never work with the keys 1.2.6 because it returns the keys as a space separated string. Sadly, there's no way to determine in that string the beginning and end of keys containing spaces.

The fix included in 2.0.1 assumes keys don't contain spaces, which is the best we can do at this point.

@skaes
Copy link
Contributor Author

skaes commented May 29, 2010

bummer. but thanks a lot for the quick reaction.

@soveran
Copy link
Collaborator

soveran commented May 29, 2010

You're welcome.

@antirez
Copy link
Contributor

antirez commented May 29, 2010

Hey soveran, skaes: my patch checked if the returned value (from the low level decoding function) was an array or a string. If it's a string, just split it. This is the relevant commit:

http://github.com/ezmobius/redis-rb/commit/07579be932511f4fd5598dbbda1f0f154d836c76

I think we should fix this for 2.0.x as well.

Cheers,
Salvatore

@soveran
Copy link
Collaborator

soveran commented May 29, 2010

antirez: yes, it's already fixed in 2.0.1. The other problem I think has no solution, though.

@antirez
Copy link
Contributor

antirez commented May 29, 2010

Sorry misunderstood the chat. The only fix is switching to Redis 2.0 indeed.

Cheers,
Salvatore

This issue was closed.
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

3 participants