aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/transactions.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-01-10 13:36:09 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-01-10 13:39:37 -0800
commitab0ce052ba23a4cce7a84ecade0d00d9cc518ebd (patch)
tree431f973e36b90deaf1c78aaa7a0ee139a4336469 /activerecord/lib/active_record/transactions.rb
parent223a1d9451c88800e9fcc93a726fdebec99e2650 (diff)
downloadrails-ab0ce052ba23a4cce7a84ecade0d00d9cc518ebd.tar.gz
rails-ab0ce052ba23a4cce7a84ecade0d00d9cc518ebd.tar.bz2
rails-ab0ce052ba23a4cce7a84ecade0d00d9cc518ebd.zip
Introduce transaction_joinable flag to mark that the fixtures transaction can't joined, a new savepoint is required even if :requires_new is not set. Use :requires_new option instead of :nest. Update changelog.
[#383 state:committed]
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r--activerecord/lib/active_record/transactions.rb27
1 files changed, 12 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index aaa298dc49..0b6e52c79b 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -137,14 +137,14 @@ module ActiveRecord
#
# User.find(:all) # => empty
#
- # It is also possible to treat a certain #transaction call as its own
- # sub-transaction, by passing <tt>:nest => true</tt> to #transaction. If
- # anything goes wrong inside that transaction block, then the parent
- # transaction will remain unaffected. For example:
+ # It is also possible to requires a sub-transaction by passing
+ # <tt>:requires_new => true</tt>. If anything goes wrong, the
+ # database rolls back to the beginning of the sub-transaction
+ # without rolling back the parent transaction. For example:
#
# User.transaction do
# User.create(:username => 'Kotori')
- # User.transaction(:nest => true) do
+ # User.transaction(:requires_new => true) do
# User.create(:username => 'Nemu')
# raise ActiveRecord::Rollback
# end
@@ -169,20 +169,17 @@ module ActiveRecord
# database error will occur because the savepoint has already been
# automatically released. The following example demonstrates the problem:
#
- # Model.connection.transaction do # BEGIN
- # Model.connection.transaction(true) do # CREATE SAVEPOINT rails_savepoint_1
- # Model.connection.create_table(...) # rails_savepoint_1 now automatically released
- # end # RELEASE savepoint rails_savepoint_1
- # # ^^^^ BOOM! database error!
+ # Model.connection.transaction do # BEGIN
+ # Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1
+ # Model.connection.create_table(...) # active_record_1 now automatically released
+ # end # RELEASE savepoint active_record_1
+ # # ^^^^ BOOM! database error!
# end
module ClassMethods
# See ActiveRecord::Transactions::ClassMethods for detailed documentation.
def transaction(options = {}, &block)
- options.assert_valid_keys :nest
-
- # See the API documentation for ConnectionAdapters::DatabaseStatements#transaction
- # for useful information.
- connection.transaction(options[:nest], &block)
+ # See the ConnectionAdapters::DatabaseStatements#transaction API docs.
+ connection.transaction(options, &block)
end
end