aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/to_sql.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-09-22 11:01:03 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-09-22 11:01:03 -0700
commitb57a11cb8abfca345f63084ce841c6f412c1156e (patch)
treec58702c92ba90e121a4556bc4053a0e6b790873f /lib/arel/visitors/to_sql.rb
parentc903c6b28933a041d42d943c6c83f98aaa81f42a (diff)
downloadrails-b57a11cb8abfca345f63084ce841c6f412c1156e.tar.gz
rails-b57a11cb8abfca345f63084ce841c6f412c1156e.tar.bz2
rails-b57a11cb8abfca345f63084ce841c6f412c1156e.zip
move the dispatch table to be per-instance
visitors are not shared among threads, so any mutations to the cache should be OK. The cache is also pre-populated on construction, but we should pull that out so we can share the cache among visitors in the future.
Diffstat (limited to 'lib/arel/visitors/to_sql.rb')
-rw-r--r--lib/arel/visitors/to_sql.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index dea6830e8f..7bef8feded 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -59,8 +59,8 @@ module Arel
DISTINCT = 'DISTINCT' # :nodoc:
def initialize connection
+ super()
@connection = connection
- @schema_cache = connection.schema_cache
end
def compile node, &block
@@ -69,6 +69,10 @@ module Arel
private
+ def schema_cache
+ @connection.schema_cache
+ end
+
def visit_Arel_Nodes_DeleteStatement o, collector
collector << "DELETE FROM "
collector = visit o.relation, collector
@@ -160,7 +164,7 @@ module Arel
end
def table_exists? name
- @schema_cache.table_exists? name
+ schema_cache.table_exists? name
end
def column_for attr
@@ -174,7 +178,7 @@ module Arel
end
def column_cache(table)
- @schema_cache.columns_hash(table)
+ schema_cache.columns_hash(table)
end
def visit_Arel_Nodes_Values o, collector