diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-09 15:56:40 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-09 15:56:40 -0700 |
commit | 8caaa08ae1cd76b26a89b0d29d50396ffd76882e (patch) | |
tree | 2505fdbe803369983b32e99a486e61ee02743543 /activerecord | |
parent | f6d46d9c2c4d4d0f49600c77d16f349ed95d408f (diff) | |
download | rails-8caaa08ae1cd76b26a89b0d29d50396ffd76882e.tar.gz rails-8caaa08ae1cd76b26a89b0d29d50396ffd76882e.tar.bz2 rails-8caaa08ae1cd76b26a89b0d29d50396ffd76882e.zip |
push the collectors up to the abstract adapter
Diffstat (limited to 'activerecord')
3 files changed, 22 insertions, 40 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 17f24dc4e0..78343cf4f5 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -6,6 +6,8 @@ require 'active_record/connection_adapters/schema_cache' require 'active_record/connection_adapters/abstract/schema_dumper' require 'active_record/connection_adapters/abstract/schema_creation' require 'monitor' +require 'arel/collectors/bind' +require 'arel/collectors/sql_string' module ActiveRecord module ConnectionAdapters # :nodoc: @@ -105,6 +107,26 @@ module ActiveRecord @prepared_statements = false end + class BindCollector < Arel::Collectors::Bind + def compile(bvs, conn) + super(bvs.map { |bv| conn.quote(*bv.reverse) }) + end + end + + class SQLString < Arel::Collectors::SQLString + def compile(bvs, conn) + super(bvs) + end + end + + def collector + if @prepared_statements + SQLString.new + else + BindCollector.new + end + end + def valid_type?(type) true end diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 4a51bddbdf..75c58ac7d9 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -198,26 +198,6 @@ module ActiveRecord end end - class BindCollector < Arel::Collectors::Bind - def compile(bvs, conn) - super(bvs.map { |bv| conn.quote(*bv.reverse) }) - end - end - - class SQLString < Arel::Collectors::SQLString - def compile(bvs, conn) - super(bvs) - end - end - - def collector - if @prepared_statements - SQLString.new - else - BindCollector.new - end - end - def adapter_name #:nodoc: self.class::ADAPTER_NAME end diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 042bf49145..f59c2432dd 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -140,26 +140,6 @@ module ActiveRecord end end - class BindCollector < Arel::Collectors::Bind - def compile(bvs, conn) - super(bvs.map { |bv| conn.quote(*bv.reverse) }) - end - end - - class SQLString < Arel::Collectors::SQLString - def compile(bvs, conn) - super(bvs) - end - end - - def collector - if @prepared_statements - SQLString.new - else - BindCollector.new - end - end - def adapter_name #:nodoc: 'SQLite' end |