From 0d63e9e8fde36c88cf60095f814e5b76edb54027 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Fri, 11 Mar 2011 07:34:14 +0000 Subject: [PATCH] scm: mercurial: add :order => 'id DESC' explicitly for MySQL test fails. 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? git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5091 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/repository/mercurial.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb index 021e60b0d..49fba82cf 100644 --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb @@ -81,16 +81,23 @@ class Repository::Mercurial < Repository # 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