View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006872||mantisbt||custom fields||public||2006-03-20 05:38||2017-10-08 23:52|
|Target Version||2.7.0||Fixed in Version||2.7.0|
|Summary||0006872: Sort of custom fields does not use data type|
I added a custom field to view_all_bug_page.php using custom_function_inc.php. The field is a "number" field (long integer) but is stored internally as string in mantis/mysql. If I click on the column header of this custom field the view gets sorted alphabetically (not numerically).
Mantis should look at the specified data type and do numeric sort instead of pure text sort.
I know mantis will support "real" numeric data types (storing real numbers in mysql database) in the future. But I think this should be fixed regardless of that feature. I personally see some advantages storing custom field values as string.
|Tags||No tags attached.|
|related to||0009120||closed||atrol||Numeric Custom fields on View All don't sort correctly|
|related to||0023265||closed||cproensa||Filter selection for numeric custom fields aren't sorted correctly on distinct values list|
|child of||0023443||closed||cproensa||Fixes related to custom fields on filters, columns and visibility|
I've got the same exact problem, Â¿could you solve it? I'd appreciate any help you can give me.
Ok, here's a workaround which should work in most cases (at least in showing those bug lists). Only integer values will be sorted correctly and there's no warranty this will work. There might be errors if you have stored non-integers! Use at your own risk.
Add the following lines into filter_api.php:
(for my installation this is around line 837)
Those 4 lines should be added after the line:
thanks a lot for your quick answer IT WORKED MORE THAN GREAT!
I don't think this is very minor as indicated here. It's a bug that needs to get fixed sooner than later. On MantisHub I had to add a regular expression to suppress leading zeroes and users now have to enter leading zeroes to sort correctly. If a type is numeric and it does not sort according to the actual value, that's a major bug.
The fixes are included in this pull request: https://github.com/mantisbt/mantisbt/pull/1183
MantisBT: master dc68e440
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
|mod - core/filter_api.php||Diff File|
|2006-03-20 05:38||stb||New Issue|
|2006-04-05 11:21||stello||Note Added: 0012466|
|2006-04-05 13:56||stb||Note Added: 0012468|
|2006-04-05 15:59||stello||Note Added: 0012470|
|2013-12-10 03:34||atrol||Relationship added||related to 0009120|
|2017-08-26 13:11||cproensa||Relationship added||related to 0023265|
|2017-08-26 13:12||cproensa||Category||customization => custom fields|
|2017-08-26 13:13||cproensa||Status||new => assigned|
|2017-08-26 13:13||cproensa||Assigned To||=> cproensa|
|2017-09-25 17:26||ShapiroCloud||Note Added: 0057815|
|2017-09-26 03:16||dregad||Note Edited: 0012468||View Revisions|
|2017-09-27 07:36||cproensa||Note Added: 0057823|
|2017-10-07 12:45||dregad||Changeset attached||=> MantisBT master dc68e440|
|2017-10-07 12:45||cproensa||Status||assigned => resolved|
|2017-10-07 12:45||cproensa||Resolution||open => fixed|
|2017-10-07 12:45||cproensa||Fixed in Version||=> 2.7.0|
|2017-10-07 13:34||atrol||Target Version||=> 2.7.0|
|2017-10-08 11:49||cproensa||Relationship added||child of 0023443|
|2017-10-08 23:52||vboctor||Status||resolved => closed|