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

Don't proxy #eval as it raises TypeError on nested namespaces #67

Merged
merged 1 commit into from
Oct 30, 2013

Conversation

rgraff
Copy link
Contributor

@rgraff rgraff commented Sep 29, 2013

Calling eval on a nested namespace causes a TypeError when proxied through method_missing. Added an eval method resolved the issue. Also added a test to make sure evalsha worked as expected when in a nested namespace. The example irb below demonstrates the error.

irb(main):002:0> first_level = Redis::Namespace.new(:one)
=> #<Redis::Namespace:0x007fd1c9123c50 @redis=#<Redis client v3.0.4 for redis://127.0.0.1:6379/0>, @warning=false, @namespace=:one>
irb(main):003:0> first_level.eval("return {KEYS[1],KEYS[2]}", :keys => ['k1','k2'], :argv => ['a'])
=> ["one:k1", "one:k2"]
irb(main):004:0> second_level = Redis::Namespace.new(:two, :redis => first_level)
=> #<Redis::Namespace:0x007fd1c90db068 @redis=#<Redis::Namespace:0x007fd1c9123c50 @redis=#<Redis client v3.0.4 for redis://127.0.0.1:6379/0>, @warning=false, @namespace=:one>, @warning=false, @namespace=:two>
irb(main):005:0> second_level.eval("return {KEYS[1],KEYS[2]}", :keys => ['k1','k2'], :argv => ['a'])
TypeError: wrong argument type Hash (expected Binding)
    from /Users/rgraff/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/redis-namespace-1.3.1/lib/redis/namespace.rb:317:in `eval'
    from /Users/rgraff/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/redis-namespace-1.3.1/lib/redis/namespace.rb:317:in `method_missing'
    from (irb):5
    from /Users/rgraff/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/railties-3.2.14/lib/rails/commands/console.rb:47:in `start'
    from /Users/rgraff/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/railties-3.2.14/lib/rails/commands/console.rb:8:in `start'
    from /Users/rgraff/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/railties-3.2.14/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

@yaauie yaauie merged commit 8adb481 into resque:master Oct 30, 2013
@yaauie
Copy link
Member

yaauie commented Oct 30, 2013

Oy, looks like it was the same issue as 6d83951 (cc:@steveklabnik). Thank you much for the report & fix. I'm hoping to do some more cleanup this week, and plan to release this coming weekend if all goes well.

@yaauie
Copy link
Member

yaauie commented Nov 3, 2013

The fix has been released is in redis-namespace-1.3.2.

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.

None yet

2 participants