diff --git a/CHANGELOG b/CHANGELOG index 9538406c83..5711abbbd6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ === HEAD +* Allow lambda procs with 0 arity as virtual row blocks on ruby 1.9 (jeremyevans) + * Handle schema-qualified row_types in the pg_array integration in the pg_row extension (jeremyevans) (#595) * Support default_schema when reseting primary key sequences on PostgreSQL (jeremyevans) (#596) diff --git a/lib/sequel/core.rb b/lib/sequel/core.rb index 9e6976fbda..0a20e448b5 100644 --- a/lib/sequel/core.rb +++ b/lib/sequel/core.rb @@ -390,7 +390,7 @@ def self.virtual_row(&block) vr = SQL::VirtualRow.new case block.arity when -1, 0 - vr.instance_eval(&block) + vr.instance_exec(&block) else block.call(vr) end diff --git a/lib/sequel/sql.rb b/lib/sequel/sql.rb index 40e5a28ea8..35ac4a6b85 100644 --- a/lib/sequel/sql.rb +++ b/lib/sequel/sql.rb @@ -6,7 +6,7 @@ module Sequel class BasicObject # The instance methods to not remove from the class when removing # other methods. - KEEP_METHODS = %w"__id__ __send__ __metaclass__ instance_eval == equal? initialize method_missing" + KEEP_METHODS = %w"__id__ __send__ __metaclass__ instance_eval instance_exec == equal? initialize method_missing" # Remove all but the most basic instance methods from the class. A separate # method so that it can be called again if necessary if you load libraries diff --git a/spec/core/expression_filters_spec.rb b/spec/core/expression_filters_spec.rb index 89af460e70..507a76f6af 100644 --- a/spec/core/expression_filters_spec.rb +++ b/spec/core/expression_filters_spec.rb @@ -594,6 +594,11 @@ def l(arg, should) l(Sequel.expr(proc{|v| @o}) + 1, "(foo + 1)") end + it "Sequel.expr should handle lambda proc virtual rows" do + l(Sequel.expr(&lambda{1}), "1") + l(Sequel.expr(&lambda{|| 1}), "1") + end + it "Sequel.expr should raise an error if given an argument and a block" do proc{Sequel.expr(nil){}}.should raise_error(Sequel::Error) end