]> source.dussan.org Git - redmine.git/commitdiff
Prevent SQL error with old sessions after r2171.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 Dec 2008 14:05:03 +0000 (14:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 Dec 2008 14:05:03 +0000 (14:05 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2183 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/boards_controller.rb
app/helpers/sort_helper.rb

index c6ce934ee001e6bab1f6e5e2f45ab481f6847483..55a9737f511881d0a11b2415b75cc808caf0f7ad 100644 (file)
@@ -42,7 +42,7 @@ class BoardsController < ApplicationController
       
     @topic_count = @board.topics.count
     @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
-    @topics =  @board.topics.find :all, :order => "#{Message.table_name}.sticky DESC, #{sort_clause}",
+    @topics =  @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
                                   :include => [:author, {:last_reply => :author}],
                                   :limit  =>  @topic_pages.items_per_page,
                                   :offset =>  @topic_pages.current.offset
index d0a2929878db97ac1f4f6754df0215f38942451a..ed520e74814514730f1b5a14c54b848b8af71bd1 100644 (file)
@@ -84,14 +84,14 @@ module SortHelper
     session[@sort_name] = sort
     
     sort_column = (sort_keys.is_a?(Hash) ? sort_keys[sort[:key]] : sort[:key])
-    @sort_clause = (sort_column.blank? ? '' : "#{sort_column} #{sort[:order]}")
+    @sort_clause = (sort_column.blank? ? nil : "#{sort_column} #{sort[:order]}")
   end
 
   # Returns an SQL sort clause corresponding to the current sort state.
   # Use this to sort the controller's table items collection.
   #
   def sort_clause()
-    @sort_clause || '' #session[@sort_name][:key] + ' ' + (session[@sort_name][:order] || 'ASC')
+    @sort_clause
   end
 
   # Returns a link which sorts by the named column.