diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 18 |
1 files changed, 16 insertions, 2 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 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. # |