aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/transactions_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Clear transaction state if callback raise rollbackArthur Neves2014-05-151-0/+13
|
* Reverts "Fix bugs with changed attributes tracking when transaction gets ↵Arthur Neves2014-05-091-42/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | rollback" We are reverting these commits, because there are other caveats related to dirty attributes not being restored when a transaction is rollback. For instance, nested transactions cannot proper restore the dirty attributes state after a rollback. At the moment, the dirty attributes are scoped by the transaction. When we call `.save` on a record, the dirty attributes will be reset even if the transaction gets rollback. [related #13166] [related #15018] [related #15016] [closes #15019] This reverts commits * bab48f0a3d53a08bc23ea0887219e8deb963c3d9 * b0fa7cf3ff8432cc2eef3682b34763b7f8c93cc8. * 73fb39b6faa9de593ae75ad4e3b8e065ea0e53af * 37c238927fbed059de3f26a90d8923fb377568a5. * 8d8d4f1560264cd1c74364d67fa0501f6dd2c4fa Revert "Merge pull request #13166 from bogdan/transaction-magic"
* Keep track of dirty attrs after after rollback.Arthur Neves2014-05-071-18/+4
| | | | [related #13166]
* Merge pull request #13166 from bogdan/transaction-magicRafael Mendonça França2014-05-071-0/+56
|\ | | | | | | [Regression 3.2 -> 4.0] Fix bugs with changed attributes tracking when transaction gets rollback
| * Fix bugs with changed attributes tracking when transaction gets rollbackBogdan Gusiev2013-12-041-0/+56
| |
* | AR .persisted? throws SystemStackError for an unsaved model with achrisfinne2014-03-271-0/+6
| | | | | | | | custom primary_key that didn't save due to validation error
* | Restore ActiveRecord states after a rollback for models w/o callbacksGodfrey Chan2014-01-181-0/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression (#13744) that was caused by 67d8bb9. In 67d8bb9, we introduced lazy rollback for records, such that the record's internal states and attributes are not restored immediately after a transaction rollback, but deferred until they are first accessed. This optimization is only performed when the model does not have any transactional callbacks (e.g. `after_commit` and `after_create`). Unfortunately, the models used to test the affected codepaths all comes with some sort of transactional callbacks. Therefore this codepath remains largely untested until now and as a result there are a few issues in the implementation that remains hidden until now. First, the `sync_with_transaction_state` (or more accurately, `update_attributes_from_transaction_state`) would perform the synchronization prematurely before a transaction is finalized (i.e. comitted or rolled back). As a result, when the actuall rollback happens, the record will incorrectly assumes that its internal states match the transaction state, and neglect to perform the restore. Second, `update_attributes_from_transaction_state` calls `committed!` in some cases. This in turns checks for the `destroyed?` state which also requires synchronization with the transaction stae, which causes an infnite recurrsion. This fix works by deferring the synchronization until the transaction has been finalized (addressing the first point), and also unrolled the `committed!` and `rolledback!` logic in-place (addressing the second point). It should be noted that the primary purpose of the `committed!` and `rolledback!` methods are to trigger the relevant transactional callbacks. Since this code path is only entered when there are no transactional callbacks on the model, this shouldn't be necessary. By unrolling the method calls, the intention here (to restore the states when necessary) becomes more clear.
* Ensure that a column added in a test is being removed after allAkira Matsuda2013-11-131-0/+7
|
* Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-14/+14
| | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.
* Assert presence of "frozen" in error message, not the full MRI message.Federico Ravasio2013-10-081-1/+3
| | | | | | | | | | Related to all the other issues regarding message independent assertions to make Rails compatible with other Ruby implementations other than MRI. The best way here would be to have a specific error raised when modifying frozen objects, like FrozenObjectError or something. But since Ruby doesn't provide such a thing, we must limit the assertion to the lowest common denominator, which is word "frozen".
* change the savepoint interface to allow passing the name.Yves Senn2013-09-301-0/+30
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-08-171-5/+0
|\ | | | | | | | | | | | | | | Conflicts: actionview/README.rdoc activerecord/lib/active_record/migration.rb guides/source/development_dependencies_install.md guides/source/getting_started.md
| * Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-5/+0
| | | | | | | | | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* | Fix indentationRafael Mendonça França2013-08-061-3/+2
| |
* | asakusa.rb hack night!Aaron Patterson + Akira Matsuda2013-08-061-0/+3
|/ | | | Fix in-memory tests
* fix order dependent testNeeraj Singh2013-07-281-0/+5
| | | | | `ReflectionTest` uses column information in tests and those tests break if tests are run in random order.
* #4566: Remove extra decrement of transaction levelPaul Nikitochkin2013-07-141-0/+14
| | | | | | | | | | | | `rollback_active_record_state!` tries to restore model state on `Exception` by invoking `restore_transaction_record_state` it decrement deep level by `1`. After restoring it ensure that states to be cleared and level decremented by invoking `clear_transaction_record_state`, which cause the bug: because state already reduced in `restore_transaction_record_state`. Removed double derement of transaction level and removed duplicated code which clear transaction state for top level.
* close our connection when we are doneAaron Patterson2013-07-081-13/+11
|
* Remove deprecated `transaction_joinable=`Arun Agrawal2013-07-031-9/+0
| | | | | in favor of `begin_transaction` with `:joinable` option.
* remove deprecated `PostgreSQLAdapter#outside_transaction?` method.Yves Senn2013-07-031-10/+0
|
* Reduced memory leak problem in transactions by lazily updating AR objects ↵wangjohn2013-02-201-2/+2
| | | | with new transaction state. If AR object has a callback, the callback will be performed immediately (non-lazily) so the transaction still has to keep records with callbacks.
* Refactored transaction state into its own object. Each transaction creates a ↵wangjohn2013-01-211-2/+10
| | | | new transaction state object upon initialization.
* Created state for a transaction and added tests.wangjohn2013-01-201-0/+20
|
* Rename update_attributes method to update, keep update_attributes as an aliasAmparo Luna + Guillermo Iguaran2013-01-031-4/+4
|
* Alias refute methods to assert_not and perfer assert_not on testsRafael Mendonça França2012-12-311-2/+2
|
* frozen state should be restored after txn is abortedAaron Patterson2012-10-221-0/+15
|
* Get rid of global variable in AR transactions testCarlos Antonio da Silva2012-09-201-7/+7
|
* Remove our use of #outside_transaction?Jon Leighton2012-09-151-29/+3
| | | | | | | | | | | | | | | | This method was first seen in 045713ee240fff815edb5962b25d668512649478, and subsequently reimplemented in fb2325e35855d62abd2c76ce03feaa3ca7992e4f. According to @jeremy, this is okay to remove. He thinks it was added because at the time we didn't have much transaction state to keep track of, and he viewed it as a hack for us to track it internally, thinking it was better to ask the connection for the transaction state. Over the years we have added more and more state to track, a lot of which is impossible to ask the connection for. So it seems that this is just a relic of the passed and we will just track the state internally only.
* Remove the transaction_open variableJon Leighton2012-09-151-0/+5
|
* Move transaction joinability into the transaction objectJon Leighton2012-09-151-0/+9
|
* Start to tease out transaction handling into a state machineJon Leighton2012-09-151-0/+1
|
* removing dead codeAaron Patterson2012-08-201-19/+7
|
* define singleton methods rather than adding and removing methodsAaron Patterson2012-08-201-45/+32
|
* remove dead codeAaron Patterson2012-08-201-78/+36
|
* Restore state on create when ActiveRecord::RecordInvalid is raisedDave Yeu2012-08-111-0/+17
| | | | This fixes issue #3217.
* Restore the frozen state on rollback. Fixes #6417.Godfrey Chan2012-05-211-0/+10
| | | | | | | | | | | | | | | | | | | | Currently, when saving a frozen record, an exception would be thrown which causes a rollback. However, there is a bug in active record that "defrost" the record as a side effect: >> t = Topic.new => #<Topic id: nil, ...> >> t.freeze => #<Topic id: nil, ...> >> t.save RuntimeError: can't modify a frozen Hash >> t.frozen? => false >> t.save => true This patch fixes the bug by explictly restoring the frozen state on the attributes Hash after every rollback.
* Automatic closure of connections in threads is deprecated. For exampleAaron Patterson2011-11-291-0/+3
| | | | | | | | | | | | | | | | | the following code is deprecated: Thread.new { Post.find(1) }.join It should be changed to close the database connection at the end of the thread: Thread.new { Post.find(1) Post.connection.close }.join Only people who spawn threads in their application code need to worry about this change.
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* persisted? should be able to return a truthy objectAaron Patterson2010-12-161-8/+8
|
* removing many unused variablesAaron Patterson2010-11-161-1/+1
|
* use persisted? instead of new_record? wherever possibleDavid Chelimsky2010-11-091-8/+8
| | | | | | | | | | | - persisted? is the API defined in ActiveModel - makes it easier for extension libraries to conform to ActiveModel APIs without concern for whether the extended object is specifically ActiveRecord [#5927 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Fix SQLite adapter name [#5842 state:resolved]Anil Wadghule2010-10-191-1/+1
|
* #transaction on the instance level should take options as wellCarl Lerche2010-10-141-0/+21
|
* Update the ActiveRecord tests to not set unused optionsCarl Lerche2010-10-131-2/+0
| | | This makes a test fail, but it is revealing a bug in Arel master.
* update_attributes and update_attributes! are now wrapped in a transactionNeeraj Singh2010-07-131-1/+22
| | | | | | [#922 state:resovled] Signed-off-by: José Valim <jose.valim@gmail.com>
* Revert "Temporarily revert "Update after_commit and after_rollback docs and ↵Jeremy Kemper2010-06-081-0/+33
| | | | | | | | tests to use new style API with an :on options instead of on_* suffix." and "Add after_commit and after_rollback callbacks to ActiveRecord that are called after transactions either commit or rollback on all records saved or destroyed in the transaction."" This reverts commit 1b2941cba1165b0721f57524645fe378bee2a950. [#2991]
* Temporarily revert "Update after_commit and after_rollback docs and tests to ↵Jeremy Kemper2010-06-081-33/+0
| | | | | | | | | | | | | | use new style API with an :on options instead of on_* suffix." and "Add after_commit and after_rollback callbacks to ActiveRecord that are called after transactions either commit or rollback on all records saved or destroyed in the transaction." This reverts commits d2a49e4b1f30c5997e169110eed94a55aee53f56 and da840d13da865331297d5287391231b1ed39721b. [#2991] Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/transactions.rb activerecord/test/cases/transaction_callbacks_test.rb
* Add after_commit and after_rollback callbacks to ActiveRecord that are ↵Brian Durand2010-04-291-14/+47
| | | | | | | | called after transactions either commit or rollback on all records saved or destroyed in the transaction. [#2991 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* squelching more warnings in the AR tests. [#4218 state:resolved]Aaron Patterson2010-03-181-6/+32
| | | | Signed-off-by: wycats <wycats@gmail.com>