From d3a8d76aa542e827dea1c2b5d500fe0801ecf3a7 Mon Sep 17 00:00:00 2001 From: Len Kranendonk Date: Tue, 12 Oct 2004 07:48:06 +0000 Subject: [PATCH] Bugfix: Default SQLReport output columns randomly ordered --- docs/changelog/6.x.x.txt | 4 ++++ lib/WebGUI/Paginator.pm | 16 ++++++++++++++++ lib/WebGUI/Wobject/SQLReport.pm | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 917742975..770c7862f 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,3 +1,7 @@ +6.3.0 + - bugfix [ 1045114 ] Columns randomly ordered in SQLReport (Len Kranendonk , + tnx brother for reporting) + 6.2.7 - Expanded upon the help for URL extensions. - Added a workaround to a bug in Time::HiRes on windows. diff --git a/lib/WebGUI/Paginator.pm b/lib/WebGUI/Paginator.pm index 48cbd6b00..5df621b9f 100644 --- a/lib/WebGUI/Paginator.pm +++ b/lib/WebGUI/Paginator.pm @@ -193,6 +193,21 @@ sub getBarTraditional { } +#------------------------------------------------------------------- + +=head2 getColumnNames ( ) + +Returns an array containing the column names + +=cut + +sub getColumnNames { + if(ref $_[0]->{_columnNames} eq 'ARRAY') { + return @{$_[0]->{_columnNames}}; + } +} + + #------------------------------------------------------------------- =head2 getFirstPageLink ( ) @@ -493,6 +508,7 @@ sub setDataByQuery { $sth = WebGUI::SQL->read($sql,$dbh); } $self->{_totalRows} = $sth->rows; + $self->{_columnNames} = [ $sth->getColumnNames ]; my $pageCount = 1; while (my $data = $sth->hashRef) { $rowCount++; diff --git a/lib/WebGUI/Wobject/SQLReport.pm b/lib/WebGUI/Wobject/SQLReport.pm index 7c83a854d..ce146ad17 100644 --- a/lib/WebGUI/Wobject/SQLReport.pm +++ b/lib/WebGUI/Wobject/SQLReport.pm @@ -140,7 +140,7 @@ sub www_view { my %row; my $colnum = 1; my @fields; - foreach my $name (keys %{$data}) { + foreach my $name ($p->getColumnNames) { if ($first) { push(@columns,{ 'column.number'=>$colnum,