aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-02-07 09:26:18 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-02-07 09:26:18 -0800
commit3cd905ee7b6ec8765cf9690b88ada5ae27fc3fd0 (patch)
tree0ada58ada98f9dd1ca43c8992924013cc33b7aaa /lib/arel/visitors
parent4d92a6b33476a5b324188bd86dfa5b5d3f4dcd3a (diff)
downloadrails-3cd905ee7b6ec8765cf9690b88ada5ae27fc3fd0.tar.gz
rails-3cd905ee7b6ec8765cf9690b88ada5ae27fc3fd0.tar.bz2
rails-3cd905ee7b6ec8765cf9690b88ada5ae27fc3fd0.zip
use the cache mechanism in the connection pool rather than our own cache
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r--lib/arel/visitors/to_sql.rb31
1 files changed, 3 insertions, 28 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index 61f68a8c09..70e10a5e0f 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -11,14 +11,6 @@ module Arel
@last_column = nil
@quoted_tables = {}
@quoted_columns = {}
- @column_cache = Hash.new { |h,pool|
- h[pool] = Hash.new { |conn_h,column|
- conn_h[column] = {}
- }
- }
- @table_exists = Hash.new { |h,pool|
- h[pool] = {}
- }
end
def accept object
@@ -91,37 +83,20 @@ key on UpdateManager using UpdateManager#key=
end
def table_exists? name
- return true if table_exists.key? name
-
- @connection.tables.each do |table|
- table_exists[table] = true
- end
-
- table_exists.key? name
- end
-
- def table_exists
- @table_exists[@pool]
+ @pool.table_exists? name
end
def column_for attr
- name = attr.name.to_sym
+ name = attr.name.to_s
table = attr.relation.name
return nil unless table_exists? table
- # If we don't have this column cached, get a list of columns and
- # cache them for this table
- unless column_cache.key? table
- columns = @connection.columns(table, "#{table}(#{name}) Columns")
- column_cache[table] = Hash[columns.map { |c| [c.name.to_sym, c] }]
- end
-
column_cache[table][name]
end
def column_cache
- @column_cache[@pool]
+ @pool.columns_hash
end
def visit_Arel_Nodes_Values o