This project is archived and is in readonly mode.

#5626 ✓resolved
Ryan Wallace

ActiveRecord generates invalid SQL when eager loading a hmt association with an order

Reported by Ryan Wallace | September 13th, 2010 @ 04:26 PM | in 2.3.10


class Author < ActiveRecord::Base
  has_many :posts
  has_many :comments_desc, :through => :posts, :source => :comments, :order => ' DESC'


Author.first(:include => :comments_desc)

Will generate the following invalid SQL:

SELECT "posts".* FROM "posts" WHERE ("posts".author_id = 1)  ORDER BY DESC

This issue was not present in 2.3.5 but occurs in 2.3.9.

I've attached a failing test case which demonstrates this issue.

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=""></a>