Patch for review: make :delete_all on has_many with :primary_key not delete unrelated records

View: New views
2 Messages — Rating Filter:   Alert me  

Patch for review: make :delete_all on has_many with :primary_key not delete unrelated records

by Matt Jones :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3086

Just what the subject says - on 2-3-stable, destroying an object with  
a has_many association using :primary_key and :delete_all will try to  
match records against the destroyed record's primary key rather than  
that declared in the association. Could cause data loss in some  
circumstances.

Patch is tiny - one line + some support functions, and includes a test.

Thanks!

--Matt Jones


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@...
To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patch for review: make :delete_all on has_many with :primary_key not delete unrelated records

by Chris Cruft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Bump.  Worth a look as this is a data corruption situation...

On Nov 3, 9:26 pm, Matt Jones <al2o...@...> wrote:

> https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3086
>
> Just what the subject says - on 2-3-stable, destroying an object with  
> a has_many association using :primary_key and :delete_all will try to  
> match records against the destroyed record's primary key rather than  
> that declared in the association. Could cause data loss in some  
> circumstances.
>
> Patch is tiny - one line + some support functions, and includes a test.
>
> Thanks!
>
> --Matt Jones
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@...
To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---