Class: ActiveRecord::ConnectionAdapters::SavepointTransaction
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Transaction
|
|
Instance Chain:
self,
Transaction
|
|
Inherits: |
ActiveRecord::ConnectionAdapters::Transaction
|
Defined in: | activerecord/lib/active_record/connection_adapters/abstract/transaction.rb |
Overview
Active Record Savepoint Transaction
Class Method Summary
Transaction
- Inherited
Instance Attribute Summary
- #full_rollback? ⇒ Boolean readonly
Transaction
- Inherited
#closed?, #connection, #dirty?, #full_rollback?, #isolation_level, #joinable?, #materialized?, #open?, | |
#restartable? | Can this transaction’s current state be recreated by rollback+begin ? |
#savepoint_name, #state, #user_transaction, #written |
Instance Method Summary
Transaction
- Inherited
Constructor Details
.new(connection, savepoint_name, parent_transaction, **options) ⇒ SavepointTransaction
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 405
def initialize(connection, savepoint_name, parent_transaction, ** ) super(connection, ** ) parent_transaction.state.add_child(@state) if isolation_level raise ActiveRecord::TransactionIsolationError, "cannot set transaction isolation in a nested transaction" end @savepoint_name = savepoint_name end
Instance Attribute Details
#full_rollback? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 445
def full_rollback?; false; end
Instance Method Details
#commit
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 439
def commit connection.release_savepoint(savepoint_name) if materialized? @state.commit! @instrumenter.finish(:commit) if materialized? end
#materialize!
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 417
def materialize! connection.create_savepoint(savepoint_name) super end
#restart
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 422
def restart return unless materialized? @instrumenter.finish(:restart) @instrumenter.start connection.rollback_to_savepoint(savepoint_name) end
#rollback
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 431
def rollback unless @state.invalidated? connection.rollback_to_savepoint(savepoint_name) if materialized? && connection.active? end @state.rollback! @instrumenter.finish(:rollback) if materialized? end