[Bps-public-commit] r20071 - DBIx-SearchBuilder/trunk/SearchBuilder/Handle

ruz at bestpractical.com ruz at bestpractical.com
Tue Jun 30 18:46:24 EDT 2009


Author: ruz
Date: Tue Jun 30 18:46:24 2009
New Revision: 20071

Modified:
   DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm
   DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm
   DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm
   DBIx-SearchBuilder/trunk/SearchBuilder/Handle/mysql.pm

Log:
* we can avoid group by checks as we do it earlier in the caller

Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm	Tue Jun 30 18:46:24 2009
@@ -246,16 +246,6 @@
     my $statementref = shift;
     my $sb = shift;
 
-    # when we have group by clause then the result set is distinct as
-    # it must contain only columns we group by or results of aggregate
-    # functions which give one result per group, so we can skip DISTINCTing
-    if ( my $group = $sb->_GroupClause ) {
-        $$statementref = "SELECT main.* FROM $$statementref";
-        $$statementref .= $group;
-        $$statementref .= $sb->_OrderClause;
-        return;
-    }
-
     my $table = $sb->Table;
 
     if ($sb->_OrderClause =~ /(?<!main)\./) {

Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Pg.pm	Tue Jun 30 18:46:24 2009
@@ -228,7 +228,7 @@
     my $table = $sb->Table;
 
     return $self->SUPER::DistinctQuery( $statementref, $sb, @_ )
-        if $sb->_GroupClause || $sb->_OrderClause !~ /(?<!main)\./;
+        if $sb->_OrderClause !~ /(?<!main)\./;
 
     # If we are ordering by something not in 'main', we need to GROUP
     # BY and adjust the ORDER_BY accordingly

Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/SQLite.pm	Tue Jun 30 18:46:24 2009
@@ -102,7 +102,7 @@
     my $sb = shift;
 
     return $self->SUPER::DistinctQuery( $statementref, $sb, @_ )
-        if $sb->_GroupClause || $sb->_OrderClause !~ /(?<!main)\./;
+        if $sb->_OrderClause !~ /(?<!main)\./;
 
     local $sb->{'group_by'} = [{FIELD => 'id'}];
     local $sb->{'order_by'} = [

Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/mysql.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/mysql.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/mysql.pm	Tue Jun 30 18:46:24 2009
@@ -82,7 +82,7 @@
     my $sb = shift;
 
     return $self->SUPER::DistinctQuery( $statementref, $sb, @_ )
-        if $sb->_GroupClause || $sb->_OrderClause !~ /(?<!main)\./;
+        if $sb->_OrderClause !~ /(?<!main)\./;
 
     if ( substr($self->DatabaseVersion, 0, 1) == 4 ) {
         local $sb->{'group_by'} = [{FIELD => 'id'}];



More information about the Bps-public-commit mailing list