aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-30 19:31:31 +0000
committerPratik Naik <pratiknaik@gmail.com>2010-01-30 19:31:31 +0000
commit11dc44ac339199680704b52402fd53f2e3c0ee07 (patch)
tree725a8062020f435f6795d38a0ae993239c6ef1df /spec
parente2dad56caae7ed7697f8d9b4e9d6a62faa308046 (diff)
downloadrails-11dc44ac339199680704b52402fd53f2e3c0ee07.tar.gz
rails-11dc44ac339199680704b52402fd53f2e3c0ee07.tar.bz2
rails-11dc44ac339199680704b52402fd53f2e3c0ee07.zip
Fix the generated SQL when In predicate is supplied an empty Array
Diffstat (limited to 'spec')
-rw-r--r--spec/arel/engines/sql/unit/predicates/in_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/arel/engines/sql/unit/predicates/in_spec.rb b/spec/arel/engines/sql/unit/predicates/in_spec.rb
index 691abcb2d2..76e5fc58df 100644
--- a/spec/arel/engines/sql/unit/predicates/in_spec.rb
+++ b/spec/arel/engines/sql/unit/predicates/in_spec.rb
@@ -45,6 +45,25 @@ module Arel
end
end
end
+
+ describe 'when the array is empty' do
+ before do
+ @array = []
+ end
+
+ it 'manufactures sql with a comma separated list' do
+ sql = In.new(@attribute, @array).to_sql
+
+ adapter_is :mysql do
+ sql.should be_like(%Q{`users`.`id` IN (NULL)})
+ end
+
+ adapter_is_not :mysql do
+ sql.should be_like(%Q{"users"."id" IN (NULL)})
+ end
+ end
+ end
+
end
describe 'when relating to a range' do