(I've had this patch lying around for a couple of weeks, waiting for Trac to come back up. noradio's already had a look at it on IRC, and I sent it to [EMAIL PROTECTED] a while ago. What's the best way to submit patches while Trac is down? Thank you for any advice on how to do this!)

with_scope doesn't support :order in the presence of :include. For example:

{{{
# We're testing the interaction between :order, :include, and with_scope.
TEST_ORDER   = 'tickets.created_at DESC'
TEST_INCLUDE = ['owner']
def test_find(opts1, opts2)
  Ticket.with_scope(:find => opts1) do
    Ticket.find(:all, opts2).map {|t| t.id }
  end
end

# In these examples, :order is respected.
test_find({ :order => TEST_ORDER }, {})
test_find({}, { :include => TEST_INCLUDE, :order => TEST_ORDER })
test_find({ :include => TEST_INCLUDE }, { :order => TEST_ORDER })

# In these examples, :order is ignored.
test_find({ :include => TEST_INCLUDE, :order => TEST_ORDER }, {})
test_find({ :order => TEST_ORDER }, { :include => TEST_INCLUDE })
}}}

There's some code duplication between construct_finder_sql_with_included_associations and the usual construct_finder_sql, and changeset r4274 for ticket #3887 only modified one copy of the duplicate code.

Attachment: with_scope_order_include.diff
Description: Binary data

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to