From 16e7273245473bb6466a79a38702a52387bab44d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 12 Aug 2010 16:19:54 -0700 Subject: full sql statement generation --- lib/arel/visitors/to_sql.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/arel/visitors') diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index ba92ca7ef1..bb2a4d07e8 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -12,6 +12,18 @@ module Arel end private + def visit_Arel_Nodes_Select o + [ + "SELECT #{o.projections.map { |x| visit x }.join ', '}", + "FROM #{o.froms.map { |x| visit x }.join ', ' }", + ("WHERE #{o.wheres.map { |x| visit x }.join ' AND ' }" unless o.wheres.blank?) + ].compact.join ' ' + end + + def visit_Arel_Table o + quote_table_name o.name + end + def visit_Arel_Nodes_Equality o "#{visit o.left} = #{visit o.right}" end -- cgit v1.2.3