diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-26 16:06:37 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-26 16:06:37 -0700 |
commit | a25b9cbc391e7040fbbbccc932339cb57d11e531 (patch) | |
tree | 11bf70293e9fcc7cddef6ca9b01caaf251577a90 /lib/arel | |
parent | 32dec29a46fda8a801c5fb2d0fc972f1b1b24a3c (diff) | |
download | rails-a25b9cbc391e7040fbbbccc932339cb57d11e531.tar.gz rails-a25b9cbc391e7040fbbbccc932339cb57d11e531.tar.bz2 rails-a25b9cbc391e7040fbbbccc932339cb57d11e531.zip |
caching quoted values
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 5ec811a53a..b9379da8cc 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -4,8 +4,10 @@ module Arel module Visitors class ToSql def initialize engine - @engine = engine - @connection = nil + @engine = engine + @connection = nil + @quoted_tables = {} + @quoted_columns = {} end def accept object @@ -67,7 +69,7 @@ module Arel def visit_Arel_Nodes_SelectStatement o [ - o.cores.map { |x| visit x }.join, + o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?), ("LIMIT #{o.limit}" if o.limit), (visit(o.offset) if o.offset), @@ -262,11 +264,11 @@ module Arel end def quote_table_name name - @connection.quote_table_name name + @quoted_tables[name] ||= @connection.quote_table_name(name) end def quote_column_name name - @connection.quote_column_name name + @quoted_columns[name] ||= @connection.quote_column_name(name) end end end |