Using negative numbers with
SUMFIELD
doesn't work. And I think it probably should. I first noticed this in 4.1.2, and just having updated to 4.2.0, find it stills exists. Plugin version is
0 (21 May 2007)
I've broken down a test case from my own use tracking expenses. it is basically as follows:
FqpTest
%EDITTABLE{include="FqpTestTable"}%
| *Item* | *Amount* |
| item | -3 |
| foo | 5 |
FqpTestSum
%TABLEFORMAT{ name=ATBLFMT header="| *Topic* | *Item* | *Amount* | " format="| [[$_up.topic][$percntICON{tag}$percnt]] | $Item | $Amount |" sort="Amount"}%
%FORMQUERY{name="fqptest" extract="FqpTestTable" search="topic=~'FqpTest' "}%
%SHOWQUERY{query="fqptest" format=ATBLFMT }%
| | %MATCHCOUNT{ query="PurchaseItemsAllocated" moan="off"}% items | %CALC{"$SUM($ABOVE())"}% Total %SUMFIELD{ query="fqptest" field="Amount"}% | |
FqpTestTable
%EDITTABLE{header="| *Item* | *Amount* |" format="| text, 20, item | text, 10, amount |" }%
| *Item* | *Amount* |
The
CALC
at the bottom of the table in
FqpTestSum
has no problem dealing with the negatives. I have tried different variations of negative specification, including using
()
around values, but to no avail.
I should also add that the negative number is just ignored; not added as a positive or anything. It seems to treat it as a non-number, and just skips over it.
--
TWiki:Main.ScottClaridge
- 14 Mar 2008
The problem actally lies in the
DBCacheContrib which underlies
FormQueryPlugin. There's a line of code in
Array.pm
:
197: } elsif ( $fieldval =~ m/^\s*\d+/o ) {
which is frankly pretty brainless (I can say that because I wrote it). This line should be fixed to recognise a generic number format (including floating point)
197: } elsif ( $fieldval =~ m/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/ ) {
Confirmed.
CC
Ahh - yes that makes all the difference.
--
TWiki:Main.ScottClaridge
- 26 Mar 2008