提交 16381289 编写于 作者: J Jon Leighton

Merge pull request #4213 from amatsuda/ar_where_array_of_nil_and_a_value

AR#where with an Array of 2 elements including a nil
......@@ -29,10 +29,13 @@ def self.build_from_hash(engine, attributes, default_table)
if values.include?(nil)
values = values.compact
if values.empty?
case values.length
when 0
array_predicates << attribute.eq(nil)
when 1
array_predicates << attribute.eq(values.first).or(attribute.eq(nil))
else
array_predicates << attribute.in(values.compact).or(attribute.eq(nil))
array_predicates << attribute.in(values).or(attribute.eq(nil))
end
else
array_predicates << attribute.in(values)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册