View Issue Details

IDProjectCategoryView StatusLast Update
0023260mantisbtcustom fieldspublic2017-10-08 23:52
Reportercproensa Assigned Tocproensa  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version2.6.0 
Target Version2.7.0Fixed in Version2.7.0 
Summary0023260: Custom fields of type date are not sorted correctly
Description

The filter query does outer join with the custom field values table.
This has three kind of values_
1) A timestamp, when there is a field related to the issue, and the field is informed.
2) An empty string, when there is a field related to the issue, and the field is not informed
3) A null value, when there is not a field related to the issue, due to the outer join.

When sorting, the result is ordered, eg: mysql: 3 < 2 < 1
Other databases may place nulls last, but still, the empty value (2) can mess the expected result.

The expected result for sorting is:

  • For ASC order, informed values (1) are placed first in asc order, and then, empty values (2) and (3) afterwards
  • For DESC order, informed values (1) are placed first in desc order, and then, empty values (2) and (3) afterwards
TagsNo tags attached.

Relationships

related to 0023241 closedcproensa Error when changing sort order in filters, due date field only 
child of 0023443 closedcproensa Fixes related to custom fields on filters, columns and visibility 

Activities

atrol

atrol

2017-08-27 04:57

developer   ~0057549

Is there any difference between 2) empty and 3) null for the end user?
I am not aware there is one, so I prefer any solution that might provide the better performance.

cproensa

cproensa

2017-08-27 06:34

developer   ~0057552

Is there any difference between 2) empty and 3) null for the end user?

Currently, i think they are treated the same, for any custom field. See for example: 0003738:0017810

My concern is, should the empty values, when that field allows empty values to be entered, be ordered before the actual data?
(This applies to other type fields too). If so, this has some difficulties like: no easy way to know (in the sql query) if the filed allows empty values
I think I prefer to leave out those empty values, and manage them with other filter options (eg, fixing 0004864 0017810)

Related Changesets

MantisBT: master dc68e440

2017-08-25 16:03

cproensa

Committer: dregad


Details Diff
Fix sorting for number based custom fields

For types numeric, float, and dates
- Make nulls appear last in the ordered result.
- Cast the values to sort them numerically.

Fixes: 0023260, 0006872
Affected Issues
0006872, 0023260
mod - core/filter_api.php Diff File