Author: spadkins
Date: Tue Sep 14 11:06:00 2010
New Revision: 14401

Modified:
   p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm

Log:
allow for db expressions in order by

Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm Tue Sep 14 11:06:00 2010
@@ -1313,18 +1313,26 @@
                 $dir = " desc";
             }
             $column_def = $table_def->{column}{$column};
-            next if (!defined $column_def);
-
-            $order_by_dbexpr = $dbexpr{$column};
-            if (!$order_by_dbexpr) {
-                $order_by_dbexpr = $column_def->{dbexpr};
-                $dbexpr{$column} = $order_by_dbexpr;
-                $self->_require_tables($order_by_dbexpr, \%reqd_tables, 
$tablealiashref, 1);
+            if (!defined $column_def) {
+                $order_by_dbexpr = $column;
             }
+            else {
+                $order_by_dbexpr = $dbexpr{$column};
+
+                if (!$order_by_dbexpr) {
+                    $order_by_dbexpr = $column_def->{dbexpr};
+                    $dbexpr{$column} = $order_by_dbexpr;
+                    $self->_require_tables($order_by_dbexpr, \%reqd_tables, 
$tablealiashref, 1);
+                }
+                
+                $columnalias = $column_def->{alias};
+                if (defined $columnidx{$column} && $columnalias) {
+                    $order_by_dbexpr = $columnalias;
+                }
+            }  
 
-            $columnalias = $column_def->{alias};
-            if (defined $columnidx{$column} && $columnalias) {
-                $order_by_dbexpr = $columnalias;
+            if ($order_by_dbexpr =~ /{/) {  #}
+                $order_by_dbexpr = $self->substitute($order_by_dbexpr, 
$params);
             }
 
             if ($order_by_dbexpr) {

Reply via email to