[Rt-commit] r3236 - in DBIx-SearchBuilder/trunk: . t
glasser at bestpractical.com
glasser at bestpractical.com
Mon Jun 20 19:55:44 EDT 2005
Author: glasser
Date: Mon Jun 20 19:55:43 2005
New Revision: 3236
Modified:
DBIx-SearchBuilder/trunk/ (props changed)
DBIx-SearchBuilder/trunk/SearchBuilder.pm
DBIx-SearchBuilder/trunk/t/01searches.t
Log:
r35257 at tin-foil: glasser | 2005-06-20 18:53:45 -0400
Fix group by / order by bug (http://rt.cpan.org/NoAuth/Bug.html?id=13060)
Modified: DBIx-SearchBuilder/trunk/SearchBuilder.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder.pm Mon Jun 20 19:55:43 2005
@@ -273,10 +273,6 @@
$self->_Handle->ApplyLimits($statementref, $self->RowsPerPage, $self->FirstRow);
$$statementref =~ s/main\.\*/join(', ', @{$self->{columns}})/eg
if $self->{columns} and @{$self->{columns}};
- if (my $groupby = $self->_GroupClause) {
- $$statementref =~ s/(LIMIT \d+)?$/$groupby $1/;
- }
-
}
@@ -402,7 +398,9 @@
$QueryString = "SELECT main.* FROM $QueryString";
}
- $QueryString .= $self->_OrderClause;
+ $QueryString .= ' ' . $self->_GroupClause . ' ';
+
+ $QueryString .= ' ' . $self->_OrderClause . ' ';
$self->_ApplyLimits(\$QueryString);
Modified: DBIx-SearchBuilder/trunk/t/01searches.t
==============================================================================
--- DBIx-SearchBuilder/trunk/t/01searches.t (original)
+++ DBIx-SearchBuilder/trunk/t/01searches.t Mon Jun 20 19:55:43 2005
@@ -8,7 +8,7 @@
BEGIN { require "t/utils.pl" }
our (@AvailableDrivers);
-use constant TESTS_PER_DRIVER => 55;
+use constant TESTS_PER_DRIVER => 59;
my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
plan tests => $total;
@@ -143,7 +143,18 @@
is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
$users_obj->Limit( FIELD => 'Phone', OPERATOR => 'IS NOT', VALUE => 'NULL', QOUTEVALUE => 0 );
is( $users_obj->Count, $count_all - 2, "found users who has phone number filled" );
-
+
+ # ORDER BY / GROUP BY
+ $users_obj->CleanSlate;
+ is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
+ $users_obj->UnLimit;
+ $users_obj->GroupByCols({FIELD => 'Login'});
+ $users_obj->OrderBy(FIELD => 'Login', ORDER => 'desc');
+ $users_obj->Column(FIELD => 'Login');
+ is( $users_obj->Count, $count_all, "group by / order by finds right amount");
+ $first_rec = $users_obj->First;
+ isa_ok( $first_rec, 'DBIx::SearchBuilder::Record', 'First returns record object' );
+ is( $first_rec->Login, 'obra', 'login is correct' );
cleanup_schema( 'TestApp', $handle );
}} # SKIP, foreach blocks
More information about the Rt-commit
mailing list