This project is archived and is in readonly mode.

#6384 ✓resolved
Raimonds Simanovskis

ActiveRecord 3.0.3 and 3-0-stable generate invalid SQL for has_many :through association with :conditions

Reported by Raimonds Simanovskis | February 7th, 2011 @ 04:47 PM

If has_many :through association has :conditions option then generated SQL is missing either join conditions or specified additional conditions from :conditions

See test case how to reproduce the issue and the generated results by different versions of ActiveRecord and Arel
https://gist.github.com/ca8d82d1dd70f73c51de

If ActiveRecord from Rails master branch and Arel master branch is used then correct SQL is generated. It would be good to fix this bug also in upcoming Rails 3.0.4 version (current version from 3-0-stable branch is producing invalid SQL).

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