Active Record Savepoint Transaction
Methods
Class Public methods
new(connection, savepoint_name, parent_transaction, **options)
📝 Source code
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 324
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
🔎 See on GitHub
Instance Public methods
commit()
📝 Source code
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 358
def commit
connection.release_savepoint(savepoint_name) if materialized?
@state.commit!
@instrumenter.finish(:commit) if materialized?
end
🔎 See on GitHub
full_rollback?()
📝 Source code
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 364
def full_rollback?; false; end
🔎 See on GitHub
materialize!()
📝 Source code
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 336
def materialize!
connection.create_savepoint(savepoint_name)
super
end
🔎 See on GitHub
restart()
📝 Source code
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 341
def restart
return unless materialized?
@instrumenter.finish(:restart)
@instrumenter.start
connection.rollback_to_savepoint(savepoint_name)
end
🔎 See on GitHub
rollback()
📝 Source code
# File activerecord/lib/active_record/connection_adapters/abstract/transaction.rb, line 350
def rollback
unless @state.invalidated?
connection.rollback_to_savepoint(savepoint_name) if materialized?
end
@state.rollback!
@instrumenter.finish(:rollback) if materialized?
end
🔎 See on GitHub