Skip to content
Browse files

caching quoted values

  • Loading branch information...
1 parent 32dec29 commit a25b9cbc391e7040fbbbccc932339cb57d11e531 @tenderlove tenderlove committed Sep 26, 2010
Showing with 11 additions and 5 deletions.
  1. +4 −0 lib/arel.rb
  2. +7 −5 lib/arel/visitors/to_sql.rb
View
4 lib/arel.rb
@@ -29,3 +29,7 @@
module Arel
VERSION = '2.0.0.dev'
end
+
+def sql raw_sql
+ Arel::Nodes::SqlLiteral.new raw_sql
+end
View
12 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 @@ def visit_Arel_Nodes_Values o
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 @@ def quote value, column = nil
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

0 comments on commit a25b9cb

Please sign in to comment.
Something went wrong with that request. Please try again.