diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-30 22:44:37 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-30 22:44:37 +0900 |
commit | df9c972afe88e3c9c65bfcd96eddca927a42b5e3 (patch) | |
tree | c175297f65f540e85bbe1ecf83df5524070f8295 /activerecord/lib/active_record/statement_cache.rb | |
parent | 859fba7c4bf7d33b4f9655914ed4bdc85380552e (diff) | |
download | rails-df9c972afe88e3c9c65bfcd96eddca927a42b5e3.tar.gz rails-df9c972afe88e3c9c65bfcd96eddca927a42b5e3.tar.bz2 rails-df9c972afe88e3c9c65bfcd96eddca927a42b5e3.zip |
Place `PartialQuery` and `PartialQueryCollector` in the same file
Diffstat (limited to 'activerecord/lib/active_record/statement_cache.rb')
-rw-r--r-- | activerecord/lib/active_record/statement_cache.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb index b41d3504fd..1b1736dcab 100644 --- a/activerecord/lib/active_record/statement_cache.rb +++ b/activerecord/lib/active_record/statement_cache.rb @@ -44,7 +44,7 @@ module ActiveRecord def initialize(values) @values = values @indexes = values.each_with_index.find_all { |thing, i| - Arel::Nodes::BindParam === thing + Substitute === thing }.map(&:last) end @@ -56,6 +56,28 @@ module ActiveRecord end end + class PartialQueryCollector + def initialize + @parts = [] + @binds = [] + end + + def <<(str) + @parts << str + self + end + + def add_bind(obj) + @binds << obj + @parts << Substitute.new + self + end + + def value + [@parts, @binds] + end + end + def self.query(sql) Query.new(sql) end @@ -64,6 +86,10 @@ module ActiveRecord PartialQuery.new(values) end + def self.partial_query_collector + PartialQueryCollector.new + end + class Params # :nodoc: def bind; Substitute.new; end end |