From 11dc44ac339199680704b52402fd53f2e3c0ee07 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 30 Jan 2010 19:31:31 +0000 Subject: Fix the generated SQL when In predicate is supplied an empty Array --- spec/arel/engines/sql/unit/predicates/in_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec') 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 -- cgit v1.2.3