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

ruz at bestpractical.com ruz at bestpractical.com
Tue Apr 1 23:01:28 EDT 2008


Author: ruz
Date: Tue Apr  1 23:01:28 2008
New Revision: 11370

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

Log:
* order on Oracle in the same way we do on other DBs

Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Handle/Oracle.pm	Tue Apr  1 23:01:28 2008
@@ -262,7 +262,14 @@
         # If we are ordering by something not in 'main', we need to GROUP
         # BY and adjust the ORDER_BY accordingly
         local $sb->{group_by} = [@{$sb->{group_by} || []}, {FIELD => 'id'}];
-        local $sb->{order_by} = [map {($_->{ALIAS} and $_->{ALIAS} ne "main") ? {%{$_}, FIELD => "min(".$_->{FIELD}.")"}: $_} @{$sb->{order_by}}];
+        local $sb->{'order_by'} = [
+            map {
+                ($_->{'ALIAS'}||'') ne "main"
+                ? { %{$_}, FIELD => ((($_->{'ORDER'}||'') =~ /^des/i)?'MAX':'MIN') ."(".$_->{FIELD}.")" }
+                : $_
+            }
+            @{$sb->{'order_by'}}
+        ];
         my $group = $sb->_GroupClause;
         my $order = $sb->_OrderClause;
         $$statementref = "SELECT main.* FROM ( SELECT main.id FROM $$statementref $group $order ) distinctquery, $table main WHERE (main.id = distinctquery.id)";



More information about the Bps-public-commit mailing list