redis-namespace icon indicating copy to clipboard operation
redis-namespace copied to clipboard

SSCAN, HSCAN, ZSCAN are not handled correctly

Open bnymn opened this issue 8 years ago • 2 comments

These commands are almost the same with SCAN command according to this documentation.

"hscan"            => [ :first ],
"hscan_each" => [ :first ],
..
"sscan"            => [ :first ],
"sscan_each" => [ :first ],
..
"zscan_each"       => [ :first ],
"zscore" => [ :first ],

They should configured like the following:

"scan"             => [ :scan_style, :second ],
"scan_each" => [ :scan_style, :all ],

I'm getting the following error if I use SSCAN command.

$redis.sscan(0)
ArgumentError: wrong number of arguments (given 1, expected 2..3)
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.2/lib/redis.rb:2603:in `sscan'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:393:in `call_with_namespace'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:290:in `method_missing'
	from (irb):5
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/console.rb:110:in `start'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/console.rb:9:in `start'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands.rb:17:in `<top (required)>'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `block in require'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
	from /ssd/Projects/news2023.com/bin/rails:9:in `<top (required)>'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `block in load'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/commands/rails.rb:6:in `call'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/command_wrapper.rb:38:in `call'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:191:in `block in serve'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:161:in `fork'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:161:in `serve'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:131:in `block in run'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:125:in `loop'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:125:in `run'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in `<top (required)>'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from -e:1:in `<main>'

bnymn avatar Feb 01 '17 15:02 bnymn

What's needed I believe is to update the method_missing in lib/redis/namespace.rb to properly pass keyword arguments, like def method_missing(command, *args, **kwargs, &block) and then call_with_namespace(command, *args, **kwargs, &block).

corincerami avatar Jun 28 '23 17:06 corincerami

Feel free to throw up a PR for this fix. I don't use those parts of Redis myself but if you have experience with them and can verify they work and include tests then that's cool with me.

PatrickTulskie avatar Jun 28 '23 18:06 PatrickTulskie