New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
after_commit is called after RELEASE SAVEPOINT #39912
Comments
Based on my understanding, I don't think this is a bug. In the example you provided, the parent transaction is created with
You'll see that the
|
Yes, exactly. The behaviour of the If your goal is to create a savepoint, you can pass Post.transaction do
Post.transaction(requires_new: true) do
Post.create!
end
end |
There is no other option but to use it, if a DBMS error-proof wrapper is being constructed. For example, say you use PostgreSQL and build an auditing library that wraps own transaction via |
This is a workaround
Usage
this is taken from Discourse's PR just curious, can we integrate this into Rails? |
This PR adds a new cop called `Rails/PrivateTransactionOption`. This cop checks whether `ActiveRecord::Base.transaction(joinable: _)` is used. The `joinable` option is a private API and is not intended to be called from outside Active Record core. rails/rails#39912 (comment) rails/rails#46182 (comment) Passing `joinable: false` may cause unexpected behavior such as the `after_commit` callback not firing at the appropriate time.
This PR adds a new cop called `Rails/PrivateTransactionOption`. This cop checks whether `ActiveRecord::Base.transaction(joinable: _)` is used. The `joinable` option is a private API and is not intended to be called from outside Active Record core. rails/rails#39912 (comment) rails/rails#46182 (comment) Passing `joinable: false` may cause unexpected behavior such as the `after_commit` callback not firing at the appropriate time.
Steps to reproduce
Expected behavior
"after commit" is outputted after COMMIT statement.
Actual behavior
"after commit" is outputted after RELEASE SAVEPOINT and before COMMIT statement.
System configuration
Rails version:
Ruby version:
The text was updated successfully, but these errors were encountered: