diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-21 15:08:54 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-21 16:09:01 -0800 |
commit | 83e42d52e37a33682fcac856330fd5d06e5a529c (patch) | |
tree | b12fad103b977689f056029dec6880f33a29a60e /activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | |
parent | a566ee5308023f1a0ea9c06e7b1b2f70cef85c87 (diff) | |
download | rails-83e42d52e37a33682fcac856330fd5d06e5a529c.tar.gz rails-83e42d52e37a33682fcac856330fd5d06e5a529c.tar.bz2 rails-83e42d52e37a33682fcac856330fd5d06e5a529c.zip |
prepared statements can be disabled
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 56ea1a2841..ad0d0d7170 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -1,6 +1,7 @@ require 'active_record/connection_adapters/abstract_adapter' require 'active_record/connection_adapters/statement_pool' require 'active_support/core_ext/string/encoding' +require 'arel/visitors/bind_visitor' module ActiveRecord module ConnectionAdapters #:nodoc: @@ -69,12 +70,21 @@ module ActiveRecord end end + class BindSubstitution < Arel::Visitors::SQLite # :nodoc: + include Arel::Visitors::BindVisitor + end + def initialize(connection, logger, config) super(connection, logger) @statements = StatementPool.new(@connection, config.fetch(:statement_limit) { 1000 }) @config = config - @visitor = Arel::Visitors::SQLite.new self + + if config.fetch(:prepared_statements) { true } + @visitor = Arel::Visitors::SQLite.new self + else + @visitor = BindSubstitution.new self + end end def adapter_name #:nodoc: @@ -210,7 +220,7 @@ module ActiveRecord # DATABASE STATEMENTS ====================================== def explain(arel, binds = []) - sql = "EXPLAIN QUERY PLAN #{to_sql(arel)}" + sql = "EXPLAIN QUERY PLAN #{to_sql(arel, binds)}" ExplainPrettyPrinter.new.pp(exec_query(sql, 'EXPLAIN', binds)) end |