diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-07 01:32:31 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-24 22:18:07 +0900 |
commit | e703de17d8bc078a0f395902b50f7080a4bba863 (patch) | |
tree | 79ccb6b144cebb09a6112c47cf42dcf22e003a0d /activerecord/lib/active_record/statement_cache.rb | |
parent | 56527bb737eb5e1d5531cafe99ce91d025565ead (diff) | |
download | rails-e703de17d8bc078a0f395902b50f7080a4bba863.tar.gz rails-e703de17d8bc078a0f395902b50f7080a4bba863.tar.bz2 rails-e703de17d8bc078a0f395902b50f7080a4bba863.zip |
Decouple statement cache from connection adapter
`StatementCache` is hard-coded in `cacheable_query` and be passed
`visitor` and `collector` from connection adapter. Simply it is
enough to pass a collected value.
Diffstat (limited to 'activerecord/lib/active_record/statement_cache.rb')
-rw-r--r-- | activerecord/lib/active_record/statement_cache.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb index 6c896ccea6..5607be6d12 100644 --- a/activerecord/lib/active_record/statement_cache.rb +++ b/activerecord/lib/active_record/statement_cache.rb @@ -40,7 +40,7 @@ module ActiveRecord end class PartialQuery < Query # :nodoc: - def initialize values + def initialize(values) @values = values @indexes = values.each_with_index.find_all { |thing,i| Arel::Nodes::BindParam === thing @@ -55,13 +55,12 @@ module ActiveRecord end end - def self.query(visitor, ast) - Query.new visitor.accept(ast, Arel::Collectors::SQLString.new).value + def self.query(sql) + Query.new(sql) end - def self.partial_query(visitor, ast, collector) - collected = visitor.accept(ast, collector).value - PartialQuery.new collected + def self.partial_query(values) + PartialQuery.new(values) end class Params # :nodoc: @@ -92,7 +91,7 @@ module ActiveRecord def self.create(connection, block = Proc.new) relation = block.call Params.new bind_map = BindMap.new relation.bound_attributes - query_builder = connection.cacheable_query relation.arel + query_builder = connection.cacheable_query(self, relation.arel) new query_builder, bind_map end |