Skip to Content Skip to Search

class ActiveRecord::ConnectionAdapters::SavepointTransaction

Active Record Savepoint Transaction

Inherits From

Public class methods

Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 325
def initialize(connection, savepoint_name, parent_transaction, **options)
  super(connection, **options)

  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

Public instance methods

Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 359
def commit
  connection.release_savepoint(savepoint_name) if materialized?
  @state.commit!
  @instrumenter.finish(:commit) if materialized?
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 365
def full_rollback?; false; end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 337
def materialize!
  connection.create_savepoint(savepoint_name)
  super
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 342
def restart
  return unless materialized?

  @instrumenter.finish(:restart)
  @instrumenter.start

  connection.rollback_to_savepoint(savepoint_name)
end
Source code GitHub
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 351
def rollback
  unless @state.invalidated?
    connection.rollback_to_savepoint(savepoint_name) if materialized? && connection.active?
  end
  @state.rollback!
  @instrumenter.finish(:rollback) if materialized?
end

Definition files