diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 10:41:06 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 10:41:06 -0800 |
commit | 6cbbbb03264bb0435cdbd589f5503baf81c67de9 (patch) | |
tree | b4b5f4d5abd2cf4c4813ce199c9d5f469b86c1c4 /lib/arel/visitors/to_sql.rb | |
parent | 05a649efeaa466dc430ea830bc6f71c6141449d9 (diff) | |
parent | 1135c2c0884bfddffa39b784d71cd3fb22bd8988 (diff) | |
download | rails-6cbbbb03264bb0435cdbd589f5503baf81c67de9.tar.gz rails-6cbbbb03264bb0435cdbd589f5503baf81c67de9.tar.bz2 rails-6cbbbb03264bb0435cdbd589f5503baf81c67de9.zip |
Merge remote branch 'sven/in-subquery' into subquery
* sven/in-subquery:
implementation for passing a subquery to #in and #not_in
tests for passing a subquery to #in and #not_in
Diffstat (limited to 'lib/arel/visitors/to_sql.rb')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index bd0d664b44..5446298189 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -101,6 +101,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, @@ -233,17 +237,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 @@ -320,6 +318,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 |