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, #records, #savepoint_name, #state
Instance Method Summary
collapse
Methods inherited from Transaction
#add_record, #before_commit_records, #closed?, #commit_records, #joinable?, #materialized?, #open?, #rollback_records
Constructor Details
#initialize(connection, savepoint_name, parent_transaction, *args, **options) ⇒ SavepointTransaction
Returns a new instance of SavepointTransaction.
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 144
def initialize(connection, savepoint_name, parent_transaction, *args, **options)
super(connection, *args, **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
166
167
168
169
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 166
def commit
connection.release_savepoint(savepoint_name) if materialized?
@state.commit!
end
|
#full_rollback? ⇒ Boolean
171
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 171
def full_rollback?; false; end
|
#materialize! ⇒ Object
156
157
158
159
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 156
def materialize!
connection.create_savepoint(savepoint_name)
super
end
|
#rollback ⇒ Object
161
162
163
164
|
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 161
def rollback
connection.rollback_to_savepoint(savepoint_name) if materialized?
@state.rollback!
end
|