This project is archived and is in readonly mode.

#6145 ✓invalid
Ari Epstein

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

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>

Pages