From fe5719fea54468f0ebcc97060df6958db17303de Mon Sep 17 00:00:00 2001 From: gmile Date: Thu, 24 Mar 2011 22:12:48 +0200 Subject: Generate more sqlish queue. 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 --- lib/arel/predications.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb index 75c4c75855..44059a54fe 100644 --- a/lib/arel/predications.rb +++ b/lib/arel/predications.rb @@ -41,7 +41,17 @@ module Arel 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 -- cgit v1.2.3