NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use trunk.foswiki.org to view this page for some minimal testing.
Use Item11383 for general documentation changes for release 1.1.5. Use Item9693 for docu changes for release 2.0.

Item5440: FormQueryPlugin: SUMFIELD broken for negative numbers

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Extension DBCacheContrib  
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

About bleeding time I fixed this....

-- CrawfordCurrie - 07 Apr 2009
Topic revision: r7 - 08 Apr 2009 - 12:29:27 - CrawfordCurrie
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads