aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-06-13 20:09:40 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2012-06-13 20:09:40 -0300
commit62207faee92c820da9fbc9cc6fe785461c2d826b (patch)
tree5c391827049475110dea8d8fafadff8f7e630d13
parentaf07bd12fd182de04a2829a5db3ae1abac299174 (diff)
downloadrails-62207faee92c820da9fbc9cc6fe785461c2d826b.tar.gz
rails-62207faee92c820da9fbc9cc6fe785461c2d826b.tar.bz2
rails-62207faee92c820da9fbc9cc6fe785461c2d826b.zip
Do not generate NOT IN (NULL) when empty right
-rw-r--r--lib/arel/visitors/to_sql.rb2
-rw-r--r--test/visitors/test_to_sql.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index a6be451e6f..cb8df8329a 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -467,7 +467,7 @@ key on UpdateManager using UpdateManager#key=
alias :visit_Arel_Nodes_Division :visit_Arel_Nodes_InfixOperation
def visit_Array o
- o.empty? ? 'NULL' : o.map { |x| visit x }.join(', ')
+ o.map { |x| visit x }.join(', ')
end
def quote value, column = nil
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index f832bdf925..58eec1f63b 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -167,10 +167,10 @@ module Arel
}
end
- it "should turn empty right to NULL" do
+ it "should return IN () when empty right which is invalid SQL" do
node = @attr.in []
@visitor.accept(node).must_be_like %{
- "users"."id" IN (NULL)
+ "users"."id" IN ()
}
end
@@ -255,10 +255,10 @@ module Arel
}
end
- it "should turn empty right to NULL" do
+ it "should return NOT IN () when empty right which is invalid SQL" do
node = @attr.not_in []
@visitor.accept(node).must_be_like %{
- "users"."id" NOT IN (NULL)
+ "users"."id" NOT IN ()
}
end