mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
extract adapter savepoint implementations into abstract/savepoints.rb
.
This commit is contained in:
parent
032998ad74
commit
78fcc5fd1a
6 changed files with 27 additions and 46 deletions
|
@ -0,0 +1,21 @@
|
|||
module ActiveRecord
|
||||
module ConnectionAdapters
|
||||
module Savepoints #:nodoc:
|
||||
def supports_savepoints?
|
||||
true
|
||||
end
|
||||
|
||||
def create_savepoint(name = current_savepoint_name)
|
||||
execute("SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def rollback_to_savepoint(name = current_savepoint_name)
|
||||
execute("ROLLBACK TO SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def release_savepoint(name = current_savepoint_name)
|
||||
execute("RELEASE SAVEPOINT #{name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -33,6 +33,7 @@ module ActiveRecord
|
|||
autoload :Quoting
|
||||
autoload :ConnectionPool
|
||||
autoload :QueryCache
|
||||
autoload :Savepoints
|
||||
end
|
||||
|
||||
autoload_at 'active_record/connection_adapters/abstract/transaction' do
|
||||
|
|
|
@ -3,6 +3,8 @@ require 'arel/visitors/bind_visitor'
|
|||
module ActiveRecord
|
||||
module ConnectionAdapters
|
||||
class AbstractMysqlAdapter < AbstractAdapter
|
||||
include Savepoints
|
||||
|
||||
class SchemaCreation < AbstractAdapter::SchemaCreation
|
||||
|
||||
def visit_AddColumn(o)
|
||||
|
@ -194,11 +196,6 @@ module ActiveRecord
|
|||
true
|
||||
end
|
||||
|
||||
# Returns true, since this connection adapter supports savepoints.
|
||||
def supports_savepoints?
|
||||
true
|
||||
end
|
||||
|
||||
def supports_bulk_alter? #:nodoc:
|
||||
true
|
||||
end
|
||||
|
@ -340,18 +337,6 @@ module ActiveRecord
|
|||
# Transactions aren't supported
|
||||
end
|
||||
|
||||
def create_savepoint(name = current_savepoint_name)
|
||||
execute("SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def rollback_to_savepoint(name = current_savepoint_name)
|
||||
execute("ROLLBACK TO SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def release_savepoint(name = current_savepoint_name)
|
||||
execute("RELEASE SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
# In the simple case, MySQL allows us to place JOINs directly into the UPDATE
|
||||
# query. However, this does not allow for LIMIT, OFFSET and ORDER. To support
|
||||
# these, we must use a subquery.
|
||||
|
|
|
@ -218,18 +218,6 @@ module ActiveRecord
|
|||
def rollback_db_transaction
|
||||
execute "ROLLBACK"
|
||||
end
|
||||
|
||||
def create_savepoint(name = current_savepoint_name)
|
||||
execute("SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def rollback_to_savepoint(name = current_savepoint_name)
|
||||
execute("ROLLBACK TO SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def release_savepoint(name = current_savepoint_name)
|
||||
execute("RELEASE SAVEPOINT #{name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -430,6 +430,7 @@ module ActiveRecord
|
|||
include ReferentialIntegrity
|
||||
include SchemaStatements
|
||||
include DatabaseStatements
|
||||
include Savepoints
|
||||
|
||||
# Returns 'PostgreSQL' as adapter name for identification purposes.
|
||||
def adapter_name
|
||||
|
@ -620,11 +621,6 @@ module ActiveRecord
|
|||
true
|
||||
end
|
||||
|
||||
# Returns true, since this connection adapter supports savepoints.
|
||||
def supports_savepoints?
|
||||
true
|
||||
end
|
||||
|
||||
# Returns true.
|
||||
def supports_explain?
|
||||
true
|
||||
|
|
|
@ -53,6 +53,8 @@ module ActiveRecord
|
|||
#
|
||||
# * <tt>:database</tt> - Path to the database file.
|
||||
class SQLite3Adapter < AbstractAdapter
|
||||
include Savepoints
|
||||
|
||||
class Version
|
||||
include Comparable
|
||||
|
||||
|
@ -351,18 +353,6 @@ module ActiveRecord
|
|||
exec_query(sql, name).rows
|
||||
end
|
||||
|
||||
def create_savepoint(name = current_savepoint_name)
|
||||
execute("SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def rollback_to_savepoint(name = current_savepoint_name)
|
||||
execute("ROLLBACK TO SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def release_savepoint(name = current_savepoint_name)
|
||||
execute("RELEASE SAVEPOINT #{name}")
|
||||
end
|
||||
|
||||
def begin_db_transaction #:nodoc:
|
||||
log('begin transaction',nil) { @connection.transaction }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue