develooper Front page | perl.cvs.p5ee | Postings from September 2010

[svn:p5ee] r14401 - p5ee/trunk/App-Repository/lib/App/Repository

From:
spadkins
Date:
September 14, 2010 11:06
Subject:
[svn:p5ee] r14401 - p5ee/trunk/App-Repository/lib/App/Repository
Message ID:
20100914180600.56273184B97@xx12.develooper.com
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) {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About