- Added the arrayRef() method to WebGUI::SQL::ResultSet, which is 12% faster

than the array() method.
 - Added more tests to the test suite.
This commit is contained in:
JT Smith 2006-07-25 17:58:54 +00:00
parent 03b4b0ed33
commit 6766c63731
4 changed files with 49 additions and 2 deletions

View file

@ -49,6 +49,9 @@
- fix: assetUiLevel override broken
- fix: Indexing files failes (derck)
- fix: Unable to approve New listings on Matrix
- Added the arrayRef() method to WebGUI::SQL::ResultSet, which is 12% faster
than the array() method.
- Added more tests to the test suite.
7.0.2

View file

@ -59,6 +59,19 @@ sub array {
return $self->sth->fetchrow_array() or $self->db->session->errorHandler->fatal("Couldn't fetch array. ".$self->errorMessage);
}
#-------------------------------------------------------------------
=head2 arrayRef ( )
Returns the next row of data as an array reference. Note that this is 12% faster than array().
=cut
sub arrayRef {
my $self = shift;
return $self->sth->fetchrow_arrayref() or $self->db->session->errorHandler->fatal("Couldn't fetch array. ".$self->errorMessage);
}
#-------------------------------------------------------------------

View file

@ -13,7 +13,7 @@ use strict;
use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use Test::More tests => 6; # increment this value for each test you create
use Test::More tests => 12; # increment this value for each test you create
my $config = WebGUI::Test->config;
my $configFile = WebGUI::Test->file;
@ -21,7 +21,34 @@ my $webguiRoot = WebGUI::Test->root;
ok( defined $config, "load config" );
ok( $config->get("dsn") ne "", "get()" );
is( ref $config->get("macros"), "HASH", "get() hash" );
is( ref $config->get("assets"), "ARRAY", "get() array" );
is( $config->getFilename,$configFile,"getFilename()" );
is( $config->getWebguiRoot, $webguiRoot, "getWebguiRoot()" );
ok( exists $WebGUI::Config::config{$configFile}, "loadAllConfigs" );
ok( defined WebGUI::Config->readAllConfigs($webguiRoot), "readAllConfigs" );
$config->addToArray("assets","TEST");
my $found = 0;
foreach my $asset ( @{$config->get("assets")}) {
$found = 1 if ($asset eq "TEST");
}
ok($found, "addToArray()");
$config->deleteFromArray("assets","TEST");
my $found = 0;
foreach my $asset ( @{$config->get("assets")}) {
$found = 1 if ($asset eq "TEST");
}
ok(!$found, "deleteFromArray()");
$config->addToHash("macros","TEST","VALUE");
my $found = 0;
foreach my $macro (keys %{$config->get("macros")}) {
$found = 1 if ($macro eq "TEST" && $config->get("macros")->{$macro} eq "VALUE");
}
ok($found, "addToHash()");
$config->deleteFromHash("macros","TEST");
my $found = 0;
foreach my $macro (keys %{$config->get("macros")}) {
$found = 1 if ($macro eq "TEST");
}
ok(!$found, "deleteFromHash()");

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use Data::Dumper;
use Test::Deep;
use Test::More tests => 49; # increment this value for each test you create
use Test::More tests => 50; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -28,6 +28,10 @@ ok(my $sth = $session->db->read("select * from settings"), "read()");
my @row = $sth->array;
is(@row, 2, "array()");
# arrayRef
my $row = $sth->arrayRef;
is(@{$row}, 2, "arrayRef()");
# getColumnNames
my @columnNames = $sth->getColumnNames;
ok($columnNames[0] eq "name" && $columnNames[1] eq "value", "geColumnNames()");