Permalink
Browse files

Fix #15481: custom field values sort order in view all page filter

Commit b5abce1 introduced a regression
in the sort order of custom field values because the query retrieving
the custom field values was rewritten with a SELECT DISTINCT instead of
using a GROUP BY clause. With MySQL, group by sorts the results, whereas
distinct does not (not tested with other RDBMS).

This fixes the issue by adding an ORDER BY clause.
  • Loading branch information...
1 parent afa498b commit 645ac2e973b99940226414299e3d8c515feea062 @dregad dregad committed Feb 9, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 core/custom_field_api.php
@@ -1161,7 +1161,8 @@ function custom_field_distinct_values( $p_field_def, $p_project_id = ALL_PROJECT
$t_query = "
SELECT DISTINCT cfst.value
FROM $t_from
- WHERE $t_where1 $t_where2";
+ WHERE $t_where1 $t_where2
+ ORDER BY cfst.value";
$t_result = db_query_bound( $t_query, $t_params );
$t_row_count = db_num_rows( $t_result );

0 comments on commit 645ac2e

Please sign in to comment.