ActiveRecord crashes on :include and :limit. is there a fix for ticket/6415?

Railsters:

Our design is just one refactor away from attaining Nirvana (and deleting a _lot_ of code!). Only this bug stands between us and enlightenment:

http://dev.rubyonrails.org/ticket/6415

Here's a synopsis:

    Frog.find( :all, :include => { :species => ['clade'] },                       :conditions => ['clade_id in (?)', 1],                       :limit => 12 )

That produces this:

ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'clade_id' in 'where clause': SELECT id FROM frogs WHERE (clade_id in (1)) LIMIT 12

That SELECT is clearly missing most of its details, including niceties like frogs.* for the result columns.

Without the :limit, it works fine (so I don't think that :offset is implicated, like the ticket says).

I'm going into ActiveRecord to monkey patch this. Has anyone tried yet?

Hi --

dblack wrote:

> Frog.find( :all, :include => { :species => ['clade'] }, > :conditions => ['clade_id in (?)', 1], > :limit => 12 )

Does it work if you change clade_id to species.clade_id?

That was it! Thanks!

I didn't think that would work because the SELECT statement was so totally broken. That didn't indicate pilot error to me.

(Also it's habtm, so it's clades_species.clade_id...)

And now a _lot_ of code that's doing a heckuva job is about to get downsized.

with_scope rules!

BTW we have both of these... (-;