aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/to_sql.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-12 16:19:54 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-12 16:19:54 -0700
commit16e7273245473bb6466a79a38702a52387bab44d (patch)
treee6958fb5be8980927d9ab1cbabfe100f8c90dad9 /lib/arel/visitors/to_sql.rb
parentd827d6e9ee10fa0906b7b3cfd191e6f9ac5d6b08 (diff)
downloadrails-16e7273245473bb6466a79a38702a52387bab44d.tar.gz
rails-16e7273245473bb6466a79a38702a52387bab44d.tar.bz2
rails-16e7273245473bb6466a79a38702a52387bab44d.zip
full sql statement generation
Diffstat (limited to 'lib/arel/visitors/to_sql.rb')
-rw-r--r--lib/arel/visitors/to_sql.rb12
1 files changed, 12 insertions, 0 deletions
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