#11132 closed enhancement (duplicate)
Sort numeric columns as numbers, not strings
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | general | Version: | |
| Severity: | normal | Keywords: | field |
| Cc: | leho@… | Branch: | |
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
Custom fields don't have a numeric option so when sorting by fields that contain numeric values (like estimatedhours from Timing and Estimation Plugin), you get orders like:
0.0, 1.0, 12.0, 120.0, 16.0, 2.0, 20.0, …
By adding these fields to the numeric_columns setting in trac.ini
[query] numeric_columns = totalhours, estimatedhours, remaininghours
the ticket queries and reports sort properly.
Attachments (1)
Change History (8)
by , 13 years ago
| Attachment: | numeric.diff added |
|---|
follow-ups: 3 6 comment:1 by , 13 years ago
| Cc: | added |
|---|
It looks like a useful feature.
Did you considered solving this by adding a new field type to TracTicketsCustomFields, or adding an option to the text field type to have the value interpreted as numeric? Maybe format = numeric?
I think your patch could be pretty much the same as it is now, except that you'd create the self.numeric_columns list by iterating over the list of dictionaries in self.fields.
One way or another, it seems desirable to directly associate the information in your numeric_columns configuration option with the custom fields configuration options.
comment:2 by , 13 years ago
| Cc: | added |
|---|
follow-up: 4 comment:3 by , 13 years ago
Replying to Ryan J Ollos <ryan.j.ollos@…>:
It looks like a useful feature.
Thanks.
Did you considered solving this by adding a new field type to TracTicketsCustomFields, or adding an option to the
textfield type to have the value interpreted as numeric? Maybeformat = numeric?
No. I'm not that smart. ;-) The basic structure of this patch is a year or two old. We knew Trac internals less well then (we understand them fairly poorly even now) and didn't, necessarily, make good architectural decisions.
I think your patch could be pretty much the same as it is now, except that you'd create the
self.numeric_columnslist by iterating over the list of dictionaries inself.fields.One way or another, it seems desirable to directly associate the information in your
numeric_columnsconfiguration option with the custom fields configuration options.
But how many other places would I have to touch that make text-oriented assumptions about custom fields?
comment:4 by , 13 years ago
Replying to Chris.Nelson@…:
But how many other places would I have to touch that make text-oriented assumptions about custom fields?
Yeah, good point. I suppose the values would continue to be stored in the database as text, and we'd want to do a cast in _fetch_ticket.
comment:5 by , 12 years ago
| Keywords: | field added |
|---|
relate this ticket by keyword, i.e. to pages like FieldRefactoring
Note, that #3080 already requested numeric fields for implementing an ordering schema other than text.
comment:6 by , 11 years ago
| Cc: | removed |
|---|---|
| Milestone: | next-dev-1.1.x |
| Resolution: | → duplicate |
| Status: | new → closed |
Replying to Ryan J Ollos <ryan.j.ollos@…>:
Did you considered solving this by adding a new field type to TracTicketsCustomFields, or adding an option to the
textfield type to have the value interpreted as numeric? Maybeformat = numeric?
#10040 implements this approach, so closing as a duplicate of that ticket.
comment:7 by , 10 years ago
| Reporter: | changed from to |
|---|



Patch to implement numeric_columns query option.