| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
`Computer` class needs to be require
See #17217 for more details
|
| |
|
|
|
|
|
|
| |
Use `commit_transaction`/`rollback_transaction` on
`within_new_transaction` method, so they make sure they `pop` the
transaction from the stack before calling the methods `commit`/`rollback`.
|
|
|
|
|
|
|
|
|
| |
Transaction class doesnt need to encapsulate the transaction state using
inheritance.
This removes all Transaction subclasses, and let the Transaction object
controls different actions based on its own state. Basically the only
actions would behave differently are `being`,`commit`,`rollback` as they
could act in a savepoint or in a real transaction.
|
| |
|
|
|
|
| |
Also add test to assets the savepoint name
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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"
|
|
|
|
| |
[related #13166]
|
|\
| |
| |
| | |
[Regression 3.2 -> 4.0] Fix bugs with changed attributes tracking when transaction gets rollback
|
| | |
|
| |
| |
| |
| | |
custom primary_key that didn't save due to validation error
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
We can conditional define the tests depending on the adapter or
connection.
Lets keep the skip for fail tests that need to be fixed.
|
|
|
|
|
|
|
|
|
|
| |
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".
|
| |
|
|\
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
actionview/README.rdoc
activerecord/lib/active_record/migration.rb
guides/source/development_dependencies_install.md
guides/source/getting_started.md
|
| |
| |
| |
| |
| |
| |
| | |
This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing
changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9.
Seems to be a code merge done by mistake.
|
| | |
|
|/
|
|
| |
Fix in-memory tests
|
|
|
|
|
| |
`ReflectionTest` uses column information in tests and those tests break
if tests are run in random order.
|
|
|
|
|
|
|
|
|
|
|
|
| |
`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.
|
| |
|
|
|
|
|
| |
in favor of `begin_transaction`
with `:joinable` option.
|
| |
|
|
|
|
| |
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.
|
|
|
|
| |
new transaction state object upon initialization.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
This fixes issue #3217.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
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? 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>
|
| |
|
| |
|