aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-09 15:45:05 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-09 15:45:05 -0700
commit42a1bf18f28c97f6f059c6edcc8f0c3732dbba71 (patch)
tree6406c09190c10e4dd868630cbaf88085ffc4d87d /activerecord/lib/active_record/connection_adapters
parent70bd5eb4bb8d4b0e285bacb397f0ce39e9d5d1d1 (diff)
downloadrails-42a1bf18f28c97f6f059c6edcc8f0c3732dbba71.tar.gz
rails-42a1bf18f28c97f6f059c6edcc8f0c3732dbba71.tar.bz2
rails-42a1bf18f28c97f6f059c6edcc8f0c3732dbba71.zip
working against arel/collector branch
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb3
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb16
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb4
3 files changed, 8 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
index f4885b19d6..270071a166 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -9,7 +9,8 @@ module ActiveRecord
# Converts an arel AST to SQL
def to_sql(arel, binds = [])
if arel.respond_to?(:ast)
- visitor.accept(arel.ast, collector).compile binds.dup
+ collected = visitor.accept(arel.ast, collector)
+ collected.compile(binds.dup, self)
else
arel
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 88c90b06bf..d297eb0236 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -183,10 +183,6 @@ module ActiveRecord
INDEX_TYPES = [:fulltext, :spatial]
INDEX_USINGS = [:btree, :hash]
- class BindSubstitution < Arel::Visitors::MySQL # :nodoc:
- include Arel::Visitors::BindVisitor
- end
-
# FIXME: Make the first parameter more similar for the two adapters
def initialize(connection, logger, connection_options, config)
super(connection, logger)
@@ -203,21 +199,17 @@ module ActiveRecord
end
class BindCollector < Arel::Collectors::Bind
- def initialize(conn)
- @conn = conn
- super()
- end
-
- def compile(bvs)
- super(bvs.map { |bv| @conn.quote(*bv.reverse) })
+ def compile(bvs, conn)
+ super(bvs.map { |bv| conn.quote(*bv.reverse) })
end
end
def collector
if @prepared_statements
+ raise
Arel::Collectors::SQLString.new
else
- BindCollector.new self
+ BindCollector.new
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
index 6cf0c94eb5..a9d260b98c 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -40,12 +40,12 @@ module ActiveRecord
def initialize(connection, logger, connection_options, config)
super
- @visitor = BindSubstitution.new self
+ @prepared_statements = false
configure_connection
end
def cacheable_query(arel)
- ActiveRecord::StatementCache.partial_query visitor, arel.ast
+ ActiveRecord::StatementCache.partial_query visitor, arel.ast, collector
end
MAX_INDEX_LENGTH_FOR_UTF8MB4 = 191