Class: ActiveRecord::ConnectionAdapters::AbstractAdapter
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::AbstractAdapter
- Includes:
- Benchmark
- Defined in:
- lib/active_record/connection_adapters/abstract_adapter.rb
Overview
All the concrete database adapters follow the interface laid down in this class. You can use this interface directly by borrowing the database connection from the Base with Base.connection.
Constant Summary collapse
- @@row_even =
true
Instance Method Summary collapse
-
#begin_db_transaction ⇒ Object
Begins the transaction (and turns off auto-committing).
-
#columns(table_name, name = nil) ⇒ Object
Returns an array of column objects for the table specified by
table_name
. -
#commit_db_transaction ⇒ Object
Commits the transaction (and turns on auto-committing).
-
#delete(sql, name = nil) ⇒ Object
Executes the delete statement.
-
#initialize(connection, logger = nil) ⇒ AbstractAdapter
constructor
:nodoc:.
-
#insert(sql, name = nil, pk = nil, id_value = nil) ⇒ Object
Returns the last auto-generated ID from the affected table.
- #quote(value, column = nil) ⇒ Object
- #quote_column_name(name) ⇒ Object
-
#reset_runtime ⇒ Object
:nodoc:.
-
#rollback_db_transaction ⇒ Object
Rollsback the transaction (and turns on auto-committing).
-
#select_all(sql, name = nil) ⇒ Object
Returns an array of record hashes with the column names as a keys and fields as values.
-
#select_one(sql, name = nil) ⇒ Object
Returns a record hash with the column names as a keys and fields as values.
-
#structure_dump ⇒ Object
Returns a string of the CREATE TABLE SQL statements for recreating the entire structure of the database.
-
#update(sql, name = nil) ⇒ Object
Executes the update statement.
Constructor Details
#initialize(connection, logger = nil) ⇒ AbstractAdapter
:nodoc:
225 226 227 228 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 225 def initialize(connection, logger = nil) # :nodoc: @connection, @logger = connection, logger @runtime = 0 end |
Instance Method Details
#begin_db_transaction ⇒ Object
Begins the transaction (and turns off auto-committing).
255 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 255 def begin_db_transaction() end |
#columns(table_name, name = nil) ⇒ Object
Returns an array of column objects for the table specified by table_name
.
237 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 237 def columns(table_name, name = nil) end |
#commit_db_transaction ⇒ Object
Commits the transaction (and turns on auto-committing).
258 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 258 def commit_db_transaction() end |
#delete(sql, name = nil) ⇒ Object
Executes the delete statement.
246 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 246 def delete(sql, name = nil) end |
#insert(sql, name = nil, pk = nil, id_value = nil) ⇒ Object
Returns the last auto-generated ID from the affected table.
240 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 240 def insert(sql, name = nil, pk = nil, id_value = nil) end |
#quote(value, column = nil) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 264 def quote(value, column = nil) case value when String then "'#{value.gsub(/\\/,'\&\&').gsub(/'/, "''")}'" # ' (for ruby-mode) when NilClass then "NULL" when TrueClass then (column && column.type == :boolean ? "'t'" : "1") when FalseClass then (column && column.type == :boolean ? "'f'" : "0") when Float, Fixnum, Bignum, Date then "'#{value.to_s}'" when Time, DateTime then "'#{value.strftime("%Y-%m-%d %H:%M:%S")}'" else "'#{value.to_yaml.gsub(/'/, "''")}'" end end |
#quote_column_name(name) ⇒ Object
276 277 278 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 276 def quote_column_name(name) return name end |
#reset_runtime ⇒ Object
:nodoc:
248 249 250 251 252 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 248 def reset_runtime # :nodoc: rt = @runtime @runtime = 0 return rt end |
#rollback_db_transaction ⇒ Object
Rollsback the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.
262 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 262 def rollback_db_transaction() end |
#select_all(sql, name = nil) ⇒ Object
Returns an array of record hashes with the column names as a keys and fields as values.
231 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 231 def select_all(sql, name = nil) end |
#select_one(sql, name = nil) ⇒ Object
Returns a record hash with the column names as a keys and fields as values.
234 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 234 def select_one(sql, name = nil) end |
#structure_dump ⇒ Object
Returns a string of the CREATE TABLE SQL statements for recreating the entire structure of the database.
281 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 281 def structure_dump() end |
#update(sql, name = nil) ⇒ Object
Executes the update statement.
243 |
# File 'lib/active_record/connection_adapters/abstract_adapter.rb', line 243 def update(sql, name = nil) end |