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

ruz at bestpractical.com ruz at bestpractical.com
Fri Nov 23 17:26:45 EST 2007


Author: ruz
Date: Fri Nov 23 17:26:44 2007
New Revision: 9731

Modified:
   DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm

Log:
* Oracle::DistinctQuery()

  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


Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm	Fri Nov 23 17:26:44 2007
@@ -245,6 +245,17 @@
     my $self = shift;
     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;
 
     # Wrapp select query in a subselect as Oracle doesn't allow



More information about the Bps-public-commit mailing list