Prevent SQL error with old sessions after r2171.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2183 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-12-27 14:05:03 +00:00
parent 03fd86034d
commit fb1f72a09c
2 changed files with 3 additions and 3 deletions

View File

@ -42,7 +42,7 @@ class BoardsController < ApplicationController
@topic_count = @board.topics.count @topic_count = @board.topics.count
@topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] @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}], :include => [:author, {:last_reply => :author}],
:limit => @topic_pages.items_per_page, :limit => @topic_pages.items_per_page,
:offset => @topic_pages.current.offset :offset => @topic_pages.current.offset

View File

@ -84,14 +84,14 @@ module SortHelper
session[@sort_name] = sort session[@sort_name] = sort
sort_column = (sort_keys.is_a?(Hash) ? sort_keys[sort[:key]] : sort[:key]) 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 end
# Returns an SQL sort clause corresponding to the current sort state. # Returns an SQL sort clause corresponding to the current sort state.
# Use this to sort the controller's table items collection. # Use this to sort the controller's table items collection.
# #
def sort_clause() def sort_clause()
@sort_clause || '' #session[@sort_name][:key] + ' ' + (session[@sort_name][:order] || 'ASC') @sort_clause
end end
# Returns a link which sorts by the named column. # Returns a link which sorts by the named column.