Class: ActiveRecord::ConnectionAdapters::SavepointTransaction
- Inherits:
-
Transaction
- Object
- Transaction
- ActiveRecord::ConnectionAdapters::SavepointTransaction
show all
- Defined in:
- lib/active_record/connection_adapters/abstract/transaction.rb
Instance Attribute Summary
Attributes inherited from Transaction
#connection, #isolation_level, #savepoint_name, #state, #written
Instance Method Summary
collapse
Methods inherited from Transaction
#add_record, #before_commit_records, #closed?, #commit_records, #joinable?, #materialized?, #open?, #records, #rollback_records
Constructor Details
#initialize(connection, savepoint_name, parent_transaction, **options) ⇒ SavepointTransaction
Returns a new instance of SavepointTransaction.
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 172
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
|
Instance Method Details
#commit ⇒ Object
194
195
196
197
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 194
def commit
connection.release_savepoint(savepoint_name) if materialized?
@state.commit!
end
|
#full_rollback? ⇒ Boolean
199
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 199
def full_rollback?; false; end
|
#materialize! ⇒ Object
184
185
186
187
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 184
def materialize!
connection.create_savepoint(savepoint_name)
super
end
|
#rollback ⇒ Object
189
190
191
192
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 189
def rollback
connection.rollback_to_savepoint(savepoint_name) if materialized?
@state.rollback!
end
|