diff options
author | gmile <iamexile@gmail.com> | 2011-03-24 22:12:48 +0200 |
---|---|---|
committer | gmile <iamexile@gmail.com> | 2011-03-24 22:12:48 +0200 |
commit | fe5719fea54468f0ebcc97060df6958db17303de (patch) | |
tree | eaf1ae679d56525ed6215554301b5aea56024031 /lib | |
parent | 2b27e653f7be7649f56b834543bcaf27e2b44c74 (diff) | |
download | rails-fe5719fea54468f0ebcc97060df6958db17303de.tar.gz rails-fe5719fea54468f0ebcc97060df6958db17303de.tar.bz2 rails-fe5719fea54468f0ebcc97060df6958db17303de.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/predications.rb | 12 |
1 files changed, 11 insertions, 1 deletions
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 |