diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-10 17:10:08 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-10 17:10:08 -0700 |
commit | 65b55b850109385195f906b88f217da88a9056a6 (patch) | |
tree | 279cd2ffe42632ef4570efe6a5d499d9d1b94434 /lib/arel | |
parent | 64f2df112410705a8c9e100b5369bbdd1e248efe (diff) | |
parent | ede507d687e23cbd5e6f8697cd65836830e0d702 (diff) | |
download | rails-65b55b850109385195f906b88f217da88a9056a6.tar.gz rails-65b55b850109385195f906b88f217da88a9056a6.tar.bz2 rails-65b55b850109385195f906b88f217da88a9056a6.zip |
Merge branch 'master' of github.com:rails/arel
* 'master' of github.com:rails/arel:
Make ToSql more thread safe.
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 73319364d5..4de497a17c 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -8,14 +8,13 @@ module Arel @engine = engine @connection = nil @pool = nil - @last_column = nil @quoted_tables = {} @quoted_columns = {} end def accept object - @last_column = nil - @pool = @engine.connection_pool + Thread.current[:arel_visitors_to_sql_last_column] = nil + @pool = @engine.connection_pool @pool.with_connection do |conn| @connection = conn super @@ -356,7 +355,7 @@ key on UpdateManager using UpdateManager#key= end def visit_Arel_Attributes_Attribute o - @last_column = column_for o + Thread.current[:arel_visitors_to_sql_last_column] = column_for o join_name = o.relation.table_alias || o.relation.name "#{quote_table_name join_name}.#{quote_column_name o.name}" end @@ -374,7 +373,7 @@ key on UpdateManager using UpdateManager#key= alias :visit_Bignum :literal alias :visit_Fixnum :literal - def quoted o; quote(o, @last_column) end + def quoted o; quote(o, Thread.current[:arel_visitors_to_sql_last_column]) end alias :visit_ActiveSupport_Multibyte_Chars :quoted alias :visit_ActiveSupport_StringInquirer :quoted |