This project is archived and is in readonly mode.
lock_version, counter cache and dependent as destroy
-
CancelProfileIsBroken
- Tag changed from activerecord to activerecord, bugmash
-
Rizwan Reza
- State changed from new to open
- Tag changed from activerecord, bugmash to activerecord, associations
Can you provide a failing test for this?
-
masone
- Importance changed from to
I tried to reproduce this one. For me it's not reproducible.
Rails 2.3.8, Ruby 1.8.7 p299, OSX
Rails 3.0.0.beta4, Ruby 1.8.7 p299, OSX
Manually tested with mysql and sqliteDid I get something wrong or is the problem fixed by now?
I used the controllers as described by Dan and the following migrations:class CreateParents < ActiveRecord::Migration def self.up create_table :parents do |t| t.integer :children_count, :default => 0 t.integer :lock_version, :default => 0 t.text :body t.timestamps end end def self.down drop_table :parents end endclass CreateChildren < ActiveRecord::Migration def self.up create_table :children do |t| t.text :body t.integer :parent_id t.timestamps end end def self.down drop_table :children end endConsole:
ruby-1.8.7-p299 > p = Parent.create(:body => 'foo') => #<Parent id: 1, children_count: 0, lock_version: 0, body: "foo", created_at: "2010-07-16 13:57:59", updated_at: "2010-07-16 13:57:59"> ruby-1.8.7-p299 > Child.create(:body => 'foo', :parent => p) => #<Child id: 1, body: "foo", parent_id: 1, created_at: "2010-07-16 13:57:59", updated_at: "2010-07-16 13:57:59"> ruby-1.8.7-p299 > Child.create(:body => 'bar', :parent => p) => #<Child id: 2, body: "bar", parent_id: 1, created_at: "2010-07-16 13:57:59", updated_at: "2010-07-16 13:57:59"> ruby-1.8.7-p299 > p.reload => #<Parent id: 1, children_count: 2, lock_version: 2, body: "foo", created_at: "2010-07-16 13:57:59", updated_at: "2010-07-16 13:57:59"> ruby-1.8.7-p299 > Parent.first.destroy => #<Parent id: 1, children_count: 2, lock_version: 2, body: "foo", created_at: "2010-07-16 13:57:59", updated_at: "2010-07-16 13:57:59">
ruby-1.8.7-p299 > Parent.all => [] ruby-1.8.7-p299 > Child.all => [] -
Jacob Burkhart
I am currently seeing this in our project. With the additional constraint that the "class Parent" (as in example of original ticket filing) uses single table inheritance.
Attaching patch with fix and test. (one for master, one for the next 2.3.x release)
-
Jacob Burkhart
- Assigned user set to Rizwan Reza
-
Santiago Pastorino
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
