Page MenuHomePhabricator

The values of properties with units need a 'no formatting' option.
Closed, ResolvedPublic

Description

Author: dan.bolser

Description:
When querying the value of a property that has custom units, there is no way to get an 'unformatted' value returned by the query.

Specifically, numbers are always full of commas (e.g. 10,004,039) and the value is always attached to a unit (separated by an " ").

I think the 'natural' way to do this would be to specify "Plain (unformatted) printouts" for the property in question

http://semantic-mediawiki.org/wiki/Help:Displaying_information#Plain_.28unformatted.29_printouts

However, SMW insists on putting commas in large numbers [1] and outputting a unit and putting a " " between the printed value and the unit.

All nice ideas in principle, but the whole point of SMW is to provide *data* not *formatting*. Currently you can't get at the underlying data, to include it in a calculation, for example, so this is a bug.

[1] http://tinyurl.com/34vuf4y

This bug is different from but related to bug 15541.


Version: unspecified
Severity: normal

Details

Reference
bz23679

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:59 PM
bzimport set Reference to bz23679.

Ok, fixed in SVN (and thus to be released with SMW 1.5.1 next week).

The unit is still shown in plain format since it is part of the data, but it is separated with a simple space (no  ), and no number formatting is applied.

dan.bolser wrote:

Cheers Markus!

Just to clarify, the above formatting takes effect only when "plain (unformatted)
printouts" are used for the property? i.e.

{{#show: Some page | ? My property # - }}

?

Given that plain (unformatted) printout is just a special case of the way units are selected, don't you think it's reasonable to suppress the output of units when using plain (unformatted) printouts?

i.e. If I say:

  • {{#show: Some page | ? My property # seconds }}
  • {{#show: Some page | ? My property # hours }}

It's clear that I want the result in seconds or hours, respectively. However, if I say:

  • {{#show: Some page | ? My property # - }}

Isn't it clear that I don't want units?

I'm being fussy about this because I want to take the values and pass them to calculations using the #expr: parser function. This won't work if their is a unit in the result.

I read somewhere that bug reports are not the place for discussions, so I'll paste this text into the thread where this issue is raised so that we can open it up for broader discussion.

Cheers,
Dan.

I now also added support for the formatting strings "-n" and "-u" to be used with Type:Number and with types with custom units. The format "-n" produces a plain number without showing the unit, the format "-u" produces the plain unit string without showing the number.