Skip to content

Passing nil in array generates improper SQL #40

Merged
merged 1 commit into from Apr 29, 2011
+11 −1
View
12 lib/arel/predications.rb
@@ -41,7 +41,17 @@ def in other
Nodes::Between.new(self, Nodes::And.new([other.begin, other.end]))
end
else
- Nodes::In.new self, other
+ if other.include?(nil)
+ if other.size > 1
+ set = Nodes::In.new self, other.compact
+ null = Nodes::Equality.new self, nil
+ Nodes::Or.new set, null
+ else
+ Nodes::Equality.new self, nil
+ end
+ else
+ Nodes::In.new self, other
+ end
end
end
Something went wrong with that request. Please try again.