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 :Quoting
|
||||||
autoload :ConnectionPool
|
autoload :ConnectionPool
|
||||||
autoload :QueryCache
|
autoload :QueryCache
|
||||||
|
autoload :Savepoints
|
||||||
end
|
end
|
||||||
|
|
||||||
autoload_at 'active_record/connection_adapters/abstract/transaction' do
|
autoload_at 'active_record/connection_adapters/abstract/transaction' do
|
||||||
|
|
|
@ -3,6 +3,8 @@ require 'arel/visitors/bind_visitor'
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
module ConnectionAdapters
|
module ConnectionAdapters
|
||||||
class AbstractMysqlAdapter < AbstractAdapter
|
class AbstractMysqlAdapter < AbstractAdapter
|
||||||
|
include Savepoints
|
||||||
|
|
||||||
class SchemaCreation < AbstractAdapter::SchemaCreation
|
class SchemaCreation < AbstractAdapter::SchemaCreation
|
||||||
|
|
||||||
def visit_AddColumn(o)
|
def visit_AddColumn(o)
|
||||||
|
@ -194,11 +196,6 @@ module ActiveRecord
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true, since this connection adapter supports savepoints.
|
|
||||||
def supports_savepoints?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def supports_bulk_alter? #:nodoc:
|
def supports_bulk_alter? #:nodoc:
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -340,18 +337,6 @@ module ActiveRecord
|
||||||
# Transactions aren't supported
|
# Transactions aren't supported
|
||||||
end
|
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
|
# 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
|
# query. However, this does not allow for LIMIT, OFFSET and ORDER. To support
|
||||||
# these, we must use a subquery.
|
# these, we must use a subquery.
|
||||||
|
|
|
@ -218,18 +218,6 @@ module ActiveRecord
|
||||||
def rollback_db_transaction
|
def rollback_db_transaction
|
||||||
execute "ROLLBACK"
|
execute "ROLLBACK"
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -430,6 +430,7 @@ module ActiveRecord
|
||||||
include ReferentialIntegrity
|
include ReferentialIntegrity
|
||||||
include SchemaStatements
|
include SchemaStatements
|
||||||
include DatabaseStatements
|
include DatabaseStatements
|
||||||
|
include Savepoints
|
||||||
|
|
||||||
# Returns 'PostgreSQL' as adapter name for identification purposes.
|
# Returns 'PostgreSQL' as adapter name for identification purposes.
|
||||||
def adapter_name
|
def adapter_name
|
||||||
|
@ -620,11 +621,6 @@ module ActiveRecord
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true, since this connection adapter supports savepoints.
|
|
||||||
def supports_savepoints?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns true.
|
# Returns true.
|
||||||
def supports_explain?
|
def supports_explain?
|
||||||
true
|
true
|
||||||
|
|
|
@ -53,6 +53,8 @@ module ActiveRecord
|
||||||
#
|
#
|
||||||
# * <tt>:database</tt> - Path to the database file.
|
# * <tt>:database</tt> - Path to the database file.
|
||||||
class SQLite3Adapter < AbstractAdapter
|
class SQLite3Adapter < AbstractAdapter
|
||||||
|
include Savepoints
|
||||||
|
|
||||||
class Version
|
class Version
|
||||||
include Comparable
|
include Comparable
|
||||||
|
|
||||||
|
@ -351,18 +353,6 @@ module ActiveRecord
|
||||||
exec_query(sql, name).rows
|
exec_query(sql, name).rows
|
||||||
end
|
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:
|
def begin_db_transaction #:nodoc:
|
||||||
log('begin transaction',nil) { @connection.transaction }
|
log('begin transaction',nil) { @connection.transaction }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue