Skip to content

Commit

Permalink
Generate more sqlish queue.
Browse files Browse the repository at this point in the history
Now, instead of the following SQL code:
  some_field IN (1, 2, NULL)

Arel will generate the proper one:
  some_field IN (1, 2) OR IS NULL
  • Loading branch information
gmile committed Mar 24, 2011
1 parent 2b27e65 commit fe5719f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/arel/predications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fe5719f

Please sign in to comment.