Fix sorting of custom columns on repository datatables

This commit is contained in:
Matej Zrimšek 2019-03-20 06:00:10 +01:00 committed by mz3944
parent 632835cf30
commit 318c322a1c

View file

@ -53,11 +53,14 @@ class RepositoryDatatableService
'repository_rows.id'] + 'repository_rows.id'] +
Extends::REPOSITORY_EXTRA_SEARCH_ATTR Extends::REPOSITORY_EXTRA_SEARCH_ATTR
repository_rows = repository_rows # Using distinct raises error when combined with sort on a custom column
.left_outer_joins(includes_json) repository_row_ids = repository_rows
.where_attributes_like(searchable_attributes, .left_outer_joins(includes_json)
search_value) .where_attributes_like(searchable_attributes,
.distinct search_value)
.pluck(:id)
.uniq
repository_rows = RepositoryRow.where(id: repository_row_ids)
end end
repository_rows repository_rows