The foswiki svn repository will become read-only on Friday 8/8. Developers should register for a http://github.com/ account for commit access to foswiki.

Item8302: Init Sorting in TablePlugin is broken if no header row.

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Extension TablePlugin  
Try any of the date sorting in TablePlugin#Examples and notice how they are incorrect.

-- AndrewJones - 07 Oct 2009

Also on trunk.

-- AndrewJones - 07 Oct 2009

On my SVN install, I had to roll back to revision 3524 to get the date sorting in the second example working. The checkin that broke it was made in Item1214 back in April.

Even back then, the first example (multiple headings) doesn't correctly sort by dates.

It looks like a fresh approach is needed to fix this.

-- AndrewJones - 07 Oct 2009

hmm plot thickens... It works fine when sorting up, but not down.

I have some unit tests that describe the problem (in 1.0.x), which I will check in, but I can't work out the problem with the code.

I will update this report if I find anything, but any help would be appreciated :-).

-- AndrewJones - 07 Oct 2009

I think your conclusion is not correct. TP sorts dates fine both up and down. I think it is the date format with dashes which is not supported so the sorting happens alphabetically. The test cases for this must be constructed so they only pass if the plugin see the format as dates and not as normal strings. Or numbers.

Example in bug report would have been nice.

-- KennethLavrsen - 08 Oct 2009

Sort by clicking header works both directions. It is initdirection up that does not work with dates.

D 10 Oct 2009   30 Nov 2009
H 11 Jan 2008 11 Jan 2008
G 12 Dec 2007 12 Dec 2007  
F 17 Oct 2007 13 Dec 2007  
E 12 Oct 2007   12 Oct 2007
C 10 Oct 2007   10 Oct 2007
B 26 Sep 2007   26 Sep 2007
A 12 Sep 2007   12 Sep 2007

A 12 Sep 2007   12 Sep 2007
B 26 Sep 2007   26 Sep 2007
C 10 Oct 2007   10 Oct 2007
E 12 Oct 2007   12 Oct 2007
F 17 Oct 2007 13 Dec 2007  
G 12 Dec 2007 12 Dec 2007  
H 11 Jan 2008 11 Jan 2008
D 10 Oct 2009   30 Nov 2009
-- KennethLavrsen - 08 Oct 2009

It is not just initdirection . If I click the following table once, it sorts them incorrectly. In fact, it does not seem to sort them at all. This is without using any %<nop>TABLE%:

When
1-Jan-2004
1-Jan-2003
2-Jan-2005

-- AndrewJones - 12 Oct 2009

It looks like Foswiki::Time::parseTime does not understand the date formatted as 1-Jan-2004, so the table I pasted above is getting sorted as a number.

However, it does understand 13 Dec 2007 as a date, so the initSort problem is still a bug.

So in fact there are two bugs here. One related to the TablePlugin, and the other in the parseTime function.

-- AndrewJones - 12 Oct 2009

I have raised Item2238 for the Foswiki::Time::parseTime issue, so this report can focus on the initdirection problem.

-- AndrewJones - 12 Oct 2009

Analysed more

This bug has nothing to do with date. The bug is

  • If you have initdirection="up"
  • AND you do not have any headerrow

then the sorting does not work at all. It tries to sort but does it wrong. Also with non-dates

Example with non-dates

F 90 13 Dec 2007  
A 40   12 Sep 2007
C 35   10 Oct 2007
E 28   12 Oct 2007
D 21   30 Nov 2009
B 20   26 Sep 2007
H 7 11 Jan 2008  
G 2 12 Dec 2007  

Dates but with headerrow. Now it sorts correctly.

Alpha PlannedSorted descending Forecast Actual
D 10 Oct 2009   30 Nov 2009
H 11 Jan 2008 11 Jan 2008  
G 12 Dec 2007 12 Dec 2007  
F 17 Oct 2007 13 Dec 2007  
E 12 Oct 2007   12 Oct 2007
C 10 Oct 2007   10 Oct 2007
B 26 Sep 2007   26 Sep 2007
A 12 Sep 2007   12 Sep 2007

Probably some index that assumes a header.

-- KennethLavrsen - 13 Oct 2009

Changed the format of the first date column to the format first reported, to verify if that is not broken as well - it is.

-- ArthurClemens - 13 Oct 2009

Andres raised Item2238 for the dashes in dates problem.

-- KennethLavrsen - 13 Oct 2009

Since 2238 is fixed I changed the example back to show the differences.

And after having looked more at the examples I can see that both up and down is broken.

The real bug is that when you have no header row the plugin assumes the first row is a header anyway.

-- KennethLavrsen - 18 Oct 2009

Looking at the code.

There is code that actively assumes that we always have a header row. You cannot make a table and sort it and get the first row sorted as well.

I am not sure this is a correct feature. I would have expected the headerrow count to be based on how many rows we have with bold content. Overridden by headerrows setting in the TABLE tag.

I am not keen on changing the code without discussion. But the sorting as such is not broken so I would call it a release blocker any longer.

-- KennethLavrsen - 18 Oct 2009

I am deferring this to 1.1. The trunk code for TablePlugin is totally rewritten and it will be too much waste work to fix this in 1.0 context.

And now that we know the nature we can live with it like we have done for many 5 or more years.

Most table do have a header.

-- KennethLavrsen - 18 Oct 2009

 

ItemTemplate edit

Summary Init Sorting in TablePlugin is broken if no header row.
ReportedBy Foswiki:Main.AndrewJones
Codebase 1.1.2
SVN Range Foswiki-1.0.7, Sun, 20 Sep 2009, build 5061
AppliesTo Extension
Component TablePlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins Foswikirev:5227 Foswikirev:10906 Foswikirev:10907
TargetRelease patch
ReleasedIn 1.1.3
Topic revision: r15 - 16 Apr 2011, KennethLavrsen
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License