From 104d0b263e5d9b17216f06c72d422d26ca5a537f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 22 Oct 2010 11:29:27 -0700 Subject: adding backwards compatibility for non-prepare statement handling drivers --- .../abstract/database_statements.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract') 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 0e4f68e85c..16d01f051b 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -4,7 +4,15 @@ module ActiveRecord # Returns an array of record hashes with the column names as keys and # column values as values. def select_all(sql, name = nil, bind_values = []) - select(sql, name, bind_values) + if supports_statement_cache? + select(sql, name, bind_values) + else + return select(sql, name) if bind_values.empty? + binds = bind_values.dup + select sql.gsub('?') { + quote(*binds.shift.reverse) + }, name + end end # Returns a record hash with the column names as keys and column values @@ -42,7 +50,7 @@ module ActiveRecord # Executes +sql+ statement in the context of this connection using # +bind_values+ as the bind substitutes. +name+ is logged along with # the executed +sql+ statement. - def exec(sql, name = nil, binds = []) + def exec(sql, name = 'SQL', binds = []) end # Returns the last auto-generated ID from the affected table. @@ -74,6 +82,12 @@ module ActiveRecord nil end + # Returns +true+ when the connection adapter supports prepared statement + # caching, otherwise returns +false+ + def supports_statement_cache? + false + end + # Runs the given block in a database transaction, and returns the result # of the block. # -- cgit v1.2.3