Index: filter_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/filter_api.php,v retrieving revision 1.152 diff -u -r1.152 filter_api.php --- filter_api.php 18 Apr 2007 06:35:01 -0000 1.152 +++ filter_api.php 26 Apr 2007 07:57:12 -0000 @@ -1049,11 +1049,11 @@ break ; case CUSTOM_FIELD_DATE_AFTER: array_push( $t_join_clauses, $t_cf_join_clause ); - $t_custom_where_clause = '(( ' . $t_table_name . '.value+0) > ' . ($t_filter['custom_fields'][$t_cfid][1]+1) . ')' ; + $t_custom_where_clause = '(( ' . $t_table_name . '.value+0 > ' . ($t_filter['custom_fields'][$t_cfid][1]+1) . ')' ; break ; default: array_push( $t_join_clauses, $t_cf_join_clause ); - $t_custom_where_clause = '(( ' . $t_table_name . '.value+0) BETWEEN ' . $t_filter['custom_fields'][$t_cfid][1] . ' AND ' . $t_filter['custom_fields'][$t_cfid][2] . ')' ; + $t_custom_where_clause = '(( ' . $t_table_name . '.value+0 BETWEEN ' . $t_filter['custom_fields'][$t_cfid][1] . ' AND ' . $t_filter['custom_fields'][$t_cfid][2] . ')' ; break ; } } else { @@ -1234,9 +1234,12 @@ if ( strpos( $c_sort, 'custom_' ) === 0 ) { $t_custom_field = substr( $c_sort, strlen( 'custom_' ) ); $t_custom_field_id = custom_field_get_id_from_name( $t_custom_field ); - $t_join .= " LEFT JOIN $t_custom_field_string_table ON ( ( $t_custom_field_string_table.bug_id = $t_bug_table.id ) AND ( $t_custom_field_string_table.field_id = $t_custom_field_id ) )"; - $c_sort = "$t_custom_field_string_table.value"; - $t_select_clauses[] = "$t_custom_field_string_table.value"; + $t_table_name = $t_custom_field_string_table . '_' . $t_custom_field_id; + $t_join .= " LEFT JOIN $t_custom_field_string_table $t_table_name ON ( ( $t_table_name.bug_id = $t_bug_table.id ) AND ( $t_table_name.field_id = $t_custom_field_id ) )"; + $c_sort = "$t_table_name.value"; + $t_select_clauses[] = "$t_table_name.value"; + + echo($t_table_name); } if ( 'DESC' == $t_dir_fields[$i] ) {