On Wednesday, January 2, 2013 4:07:42 PM UTC-8, rohit wrote:
>
> On Tuesday, January 4, 2011 6:58:31 PM UTC-6, Jeremy Evans wrote:
>
>>   class Proc 
>>     def sql_literal(ds) 
>>       ds.literal(Sequel.virtual_row(&self)) 
>>     end 
>>   end 
>>
>> Jeremy
>
>
> Hi Jeremy,
>
> This nice solution does not work in Ruby 1.9.3
>
> ArgumentError: wrong number of arguments (1 for 0)
> from 
> /home/rohit/.rvm/gems/ruby-1.9.3-p362/gems/sequel-3.42.0/lib/sequel/core.rb:395:in
>  
> `instance_eval'
> from 
> /home/rohit/.rvm/gems/ruby-1.9.3-p362/gems/sequel-3.42.0/lib/sequel/core.rb:395:in
>  
> `virtual_row'
> from 
> /home/rohit/.rvm/gems/ruby-1.9.3-p362/gems/sequel-3.42.0/lib/sequel/dataset/query.rb:1147:in
>  
> `virtual_row_columns'
> from 
> /home/rohit/.rvm/gems/ruby-1.9.3-p362/gems/sequel-3.42.0/lib/sequel/dataset/query.rb:779:in
>  
> `select'
>
> Can be made to work by changing lambda to Proc.new. Is there a better way?
>

You can use a regular proc instead of a lambda proc, or you can use 
lambda{|*a|} so that the lambda accepts an argument.  You could also use a 
lambda with a single argument, but then you can't use the instance_eval 
virtual row form.

I think it is possible to make your code work directly in Sequel using 
instance_exec instead of instance_eval.  Now that we no longer support ruby 
1.8.6, we can make that switch.  I'll add that to my todo list.

Thanks,
Jeremy

 Don't use a lambda?  You could optionally use a lambda that accepts an 
argument, but th

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/jJGxFEVplWAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to