mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 11:37:14 +00:00
Adds missing join when ordering by authsource (#37674).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21856 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f7e611dfd0
commit
8cf28048a4
@ -153,4 +153,16 @@ class UserQuery < Query
|
||||
#{sql_for_field(:mail, operator, value, emails, 'address')})
|
||||
SQL
|
||||
end
|
||||
|
||||
def joins_for_order_statement(order_options)
|
||||
joins = [super]
|
||||
|
||||
if order_options
|
||||
if order_options.include?('auth_source')
|
||||
joins << "LEFT OUTER JOIN #{AuthSource.table_name} auth_sources ON auth_sources.id = #{queried_table_name}.auth_source_id"
|
||||
end
|
||||
end
|
||||
|
||||
joins.any? ? joins.join(' ') : nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -169,6 +169,19 @@ class UserQueryTest < ActiveSupport::TestCase
|
||||
assert_not users.map(&:id).include? 1
|
||||
end
|
||||
|
||||
def test_auth_source_ordering
|
||||
user = User.find(1)
|
||||
user.update_column :auth_source_id, 1
|
||||
|
||||
q = UserQuery.new name: '_'
|
||||
q.column_names = ['id', 'auth_source.name']
|
||||
q.sort_criteria = 'auth_source.name'
|
||||
|
||||
users = q.results_scope
|
||||
assert users.many?
|
||||
assert_equal user, users.last
|
||||
end
|
||||
|
||||
def find_users_with_query(query)
|
||||
User.where(query.statement).to_a
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user