This project is archived and is in readonly mode.
Transaction block sets model ID to non-existent row
-
Farrel
Whoops, here's the code block formatted correctly:
>> client_user = new_client_user( :first_name => nil ) # Will cause validation to fail => #<ClientUser id: nil, login: "rene173744", email_address: "far...@bosman.com", first_name: nil, last_name: "Sim", active: true> >> establishment = new_establishment( :brand => brand ) => #<Establishment id: nil, brand_id: 4, name: "Pretoria GrandWest" ,active: true> >> Establishment.transaction{ establishment.save!; client_user.save! } rescue false => false >> establishment.id => 10 >> establishment.new_record? => false >> client_user.id => nil >> establishment.reload ActiveRecord::RecordNotFound: Couldn't find Establishment with ID=10 ... >> Establishment.count => 4 -
CancelProfileIsBroken
- Tag set to bugmash
-
John Trupiano
Failing test case patch attached. Problem still unresolved.
-
David Trasbo
verified
Reproducible in Rails 2.3.2 using MySQL.
-
Rizwan Reza
verified
+1 This is a relatively important bug. The test case fails.
-
Derander
+1 verified.
Ran the test, the test seems to be appropriate. Does fail.
-
Hugo Peixoto
verified in master.
+1 does seem like an important bug. -
Tristan Dunn
+1
Verified on master, but seems like it's going to be a fairly tricky fix.
-
Jeremy Kemper
- Assigned user set to Jeremy Kemper
- State changed from new to open
Fixing this well is difficult without piling on more hacks. It points to a missing Transaction class to encapsulate this behavior, including records "enrolled" in the transaction.
-
Joe Van Dyk
+1 verified on sqlite3 as well.
-
Elad Meidar
+1 verified Mysql and sqlite 3 Sounds like some kind of a GC is required when rescuing within a transaction. i traced it up until
rollback_active_record_state!on transactions.rb, but it seems that the rollback is being preformed only on the instance that raised the exception and not all instances in the transaction as it should. -
Pieter
+1 verified mysql and sqlite3.
see below for an rspec example which shows the unexpected behaviour
require 'spec_helper'
describe Author do
self.use_transactional_fixtures = falseafter(:each) do
{mkd-extraction-c86ddf888e2dd7a0001e9ea8099dc0d0}end
it "should behave normal when using transactions" do
{mkd-extraction-0fc41ba6a9a845baba6e5580443a47ac}end end
-
Amit
+1 breaks nested forms with validation.
Isn't it a critical issue? basically it means that transactions containing multiple objects doesn't work.
-
Santiago Pastorino
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
