This project is archived and is in readonly mode.
Generate valid sql for ActiveRecord::Reflection with polymorphic aspect through dependent_conditions method
Reported by Ari Epstein | December 10th, 2010 @ 05:06 PM
When I do the following an error is raised:
class Post < ActiveRecord::Base
has_many :taggings, :as => :taggable, :dependent => :delete_all
end
Post.create!
Post.destroy
I get something like this:
Mysql::Error: Unknown column 'taggable' in 'where clause': DELETE FROM `taggings` WHERE ((taggable = 30) AND (taggable_type = 'Post')) (ActiveRecord::StatementInvalid)
The apparent problem is a defect in the dependent_conditions method of the Reflection class, which generates invalid sql for polymorphic associations. I have attached a patch with a test. This was not an issue in the 2.3 branch. Hopefully it can be resolved quickly?
Comments and changes to this ticket
-
Ari Epstein December 10th, 2010 @ 05:10 PM
- Tag changed from activerecord 3.0, associations, has_many, polymorphic, reflection to activerecord 3.0, associations, has_many, patch, polymorphic, reflection
-
Ari Epstein December 10th, 2010 @ 05:29 PM
Ack! This should be closed -- it appears to be a bug in the composite_primary_keys gem.
-
Piotr Sarnacki December 11th, 2010 @ 09:53 AM
- State changed from new to invalid
- Importance changed from to Low
Ok, closing.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>