From 16ee8f66bcc527406e44c28a441e8f25481c5a0d Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 7 Dec 2010 10:05:42 +0100 Subject: implementation for passing a subquery to #in and #not_in --- lib/arel/visitors/to_sql.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/arel/visitors') diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 2fb464b265..6fc206c12c 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -72,6 +72,10 @@ module Arel }.join ', '})" end + def visit_Arel_SelectManager o + o.to_sql + end + def visit_Arel_Nodes_SelectStatement o [ o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, @@ -204,17 +208,11 @@ module Arel end def visit_Arel_Nodes_In o - right = o.right - "#{visit o.left} IN (#{ - right.empty? ? 'NULL' : right.map { |x| visit x }.join(', ') - })" + "#{visit o.left} IN (#{visit o.right})" end def visit_Arel_Nodes_NotIn o - right = o.right - "#{visit o.left} NOT IN (#{ - right.empty? ? 'NULL' : right.map { |x| visit x }.join(', ') - })" + "#{visit o.left} NOT IN (#{visit o.right})" end def visit_Arel_Nodes_And o @@ -291,6 +289,10 @@ module Arel alias :visit_ActiveSupport_StringInquirer :visit_String alias :visit_Class :visit_String + def visit_Array o + o.empty? ? 'NULL' : o.map { |x| visit x }.join(', ') + end + def quote value, column = nil @connection.quote value, column end -- cgit v1.2.3