In a project I want to be able to do this....
class Ticket
has n, :ticket_statuses, :order => [:created_at.desc]
has n, :statuses, :through => :ticket_statuses
end
If I call 'ticket.ticket_statuses' I get the following query:
SELECT "ticket_id", "status_id", "created_at" FROM "ticket_statuses" WHERE ("ticket_id" IN ('8D5T-DWUNUG')) ORDER BY "created_at" DESC
But if I call 'ticket.statuses' I get
SELECT "statuses"."id", "statuses"."name", "statuses"."object_class" FROM "statuses" INNER JOIN "ticket_statuses" ON ("statuses"."id" = "ticket_statuses"."status_id") WHERE ("ticket_statuses"."ticket_id" = '8D5T-DWUNUG') GROUP BY "statuses"."id", "statuses"."name", "statuses"."object_class" ORDER BY "statuses"."id"
I then tried to specify the has n, :statuses as:
has n, :statuses, :through => :ticket_statuses, :order => ["ticket_statuses.created_at DESC"] and has n, :statuses, :through => :ticket_statuses, :order => ["ticket_statuses.created_at.desc"]
But both of these fail with
ArgumentError: Unknown property 'ticket_statuses.created_at.desc'
Is it a bug that I cannot apply an order to a join table in this way, or a feature?
Created by David Smalley - 2008-09-30 17:38:54 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/580
该提问来源于开源项目:datamapper/dm-core