aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/predications.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-04-29 10:05:40 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-04-29 10:05:40 -0700
commit490d6f98f8974c717ddca29df162f5f1ad48e094 (patch)
treee8bc316708d8c2478c62e1aa2055d7f0a598da51 /lib/arel/predications.rb
parentdd07005dceb6641214f7d1166f75acbd379fb570 (diff)
parentfe5719fea54468f0ebcc97060df6958db17303de (diff)
downloadrails-490d6f98f8974c717ddca29df162f5f1ad48e094.tar.gz
rails-490d6f98f8974c717ddca29df162f5f1ad48e094.tar.bz2
rails-490d6f98f8974c717ddca29df162f5f1ad48e094.zip
Merged pull request #40 from gmile/master.
Passing nil in array generates improper SQL
Diffstat (limited to 'lib/arel/predications.rb')
-rw-r--r--lib/arel/predications.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb
index 08cbf16d9d..36eae074a8 100644
--- a/lib/arel/predications.rb
+++ b/lib/arel/predications.rb
@@ -42,7 +42,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