# Returns the latest changesets for +path+; sorted by revision number
# Default behavior is to search in cached changesets
+ #
+ # Because :order => 'id DESC' is defined at 'has_many',
+ # there is no need to set 'order'.
+ # But, MySQL test fails.
+ # Sqlite3 and PostgreSQL pass.
+ # Is this MySQL bug?
def latest_changesets(path, rev, limit=10)
if path.blank?
- changesets.find(:all, :include => :user, :limit => limit)
+ changesets.find(:all, :include => :user, :limit => limit, :order => 'id DESC')
else
changesets.find(:all, :select => "DISTINCT #{Changeset.table_name}.*",
:joins => :changes,
:conditions => ["#{Change.table_name}.path = ? OR #{Change.table_name}.path LIKE ? ESCAPE ?",
path.with_leading_slash,
"#{path.with_leading_slash.gsub(/[%_\\]/) { |s| "\\#{s}" }}/%", '\\'],
- :include => :user, :limit => limit)
+ :include => :user, :limit => limit,
+ :order => "#{Changeset.table_name}.id DESC" )
end
end