diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-17 11:22:45 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-17 11:22:45 -0800 |
commit | a0d704aa59e1d4c255107f38a783bb79391635c8 (patch) | |
tree | 9cdf15c5e3a2e0bb51374a4faaf0381ba64373ab /activerecord/lib | |
parent | 9c04b55e52b50ced257dc215071605aa6291fc30 (diff) | |
download | rails-a0d704aa59e1d4c255107f38a783bb79391635c8.tar.gz rails-a0d704aa59e1d4c255107f38a783bb79391635c8.tar.bz2 rails-a0d704aa59e1d4c255107f38a783bb79391635c8.zip |
don't cache the connection (because we don't need to)
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/statement_cache.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb index 46c8bcc9c5..677b637a59 100644 --- a/activerecord/lib/active_record/statement_cache.rb +++ b/activerecord/lib/active_record/statement_cache.rb @@ -17,19 +17,18 @@ module ActiveRecord Substitute = Struct.new :name class Query - def initialize(connection, sql) - @connection = connection + def initialize(sql) @sql = sql end - def sql_for(binds) + def sql_for(binds, connection) @sql end end class PartialQuery < Query - def sql_for(binds) - @sql.gsub(/\?/) { @connection.quote(*binds.shift.reverse) } + def sql_for(binds, connection) + @sql.gsub(/\?/) { connection.quote(*binds.shift.reverse) } end end @@ -37,9 +36,9 @@ module ActiveRecord Query.new connection, visitor.accept(ast) end - def self.partial_query(connection, visitor, ast) + def self.partial_query(visitor, ast) sql = visitor.accept(ast) { "?" } - PartialQuery.new connection, sql + PartialQuery.new sql end class Params @@ -84,7 +83,7 @@ module ActiveRecord bind_values = bind_map.bind params builder = query_builder klass.connection, arel - sql = builder.sql_for bind_values + sql = builder.sql_for bind_values, klass.connection klass.find_by_sql sql, bind_values end |