lib/philtre/grinder.rb in philtre-0.1.1 vs lib/philtre/grinder.rb in philtre-0.1.2
- old
+ new
@@ -122,11 +122,18 @@
# can't use nil for all kinds of expressions because nil mean NULL for
# most of the Sequel::SQL expressions.
obj.clone Hash[ v(obj.opts).map{|k,val| [k, val.is_a?(Philtre::EmptyExpression) ? false : val]} ]
# for Sequel::Models
- when ->(obj){obj.respond_to? :dataset}
- v obj.dataset
+ when -> obj { obj.is_a?(Class) && obj.ancestors.include?(Sequel::Model) }
+ # From sequel-5.x.x, I suspect,
+ # SomeModel.dataset.opts includes :row_proc => SomeModel and :model => SomeModel
+ # which sends v into an endless loop.
+ opts = obj.dataset.opts.reject{|_,v| v == obj}
+ transformed = v(opts).map do |k,val|
+ [k, val.is_a?(Philtre::EmptyExpression) ? false : val]
+ end
+ obj.dataset.clone Hash[transformed]
# for other things that are convertible to dataset
when ->(obj){obj.respond_to? :to_dataset}
v obj.to_dataset