• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5440: FormQueryPlugin: SUMFIELD broken for negative numbers

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension DBCacheContrib Normal Confirmed   n/a  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


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:


| *Item* | *Amount* |
| item | -3 |
| foo | 5 |


%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"}% | |


 %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]+)?/ ) {



Ahh - yes that makes all the difference.

-- TWiki:Main.ScottClaridge - 26 Mar 2008

Summary FormQueryPlugin: SUMFIELD broken for negative numbers
ReportedBy TWiki:Main.ScottClaridge
Codebase 4.1.2, 4.2.0
SVN Range

AppliesTo Extension
Component DBCacheContrib
Priority Normal
CurrentState Confirmed


TargetRelease n/a

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r4 - 2008-03-26 - ScottClaridge
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback