diff options
author | Keenan Brock <keenan@thebrocks.net> | 2017-03-09 11:48:44 -0500 |
---|---|---|
committer | Keenan Brock <keenan@thebrocks.net> | 2017-11-06 13:59:03 -0500 |
commit | 01c703248396528d9f3398d0f9d0143831e9d0dc (patch) | |
tree | d197f58651d504874ef04ac04b92a4a275c04780 /activerecord/lib/active_record/attribute_methods/query.rb | |
parent | 204b22fa1c739e07d8487ace5710f8f2abe27c0e (diff) | |
download | rails-01c703248396528d9f3398d0f9d0143831e9d0dc.tar.gz rails-01c703248396528d9f3398d0f9d0143831e9d0dc.tar.bz2 rails-01c703248396528d9f3398d0f9d0143831e9d0dc.zip |
Properly check transaction in persistence
```
[NoMethodError]: undefined method `state' for nil:NilClass Method:[rescue in block in refresh]
```
In `within_new_transaction`, there is the possibility that
`begin_transaction` returns a `nil`. (i.e.: so `transaction = nil`)
So this method is checking `transaction` for nil in 2 spots.
Unfortunately, there is one line that is not checking `transaction` for `nil`
That line, `commit_transaction`, throws an exception for us in AR 5.0.0.1
The problem with the method is finally realized in the error checking itself.
it calls `transaction.state` (i.e.: nil.state) and that is the final exception
raised.
The actual underlying (user) issue is hidden by this line.
Solution is test transaction for nil.
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/query.rb')
0 files changed, 0 insertions, 0 deletions