Author: jzucker
Date: Thu Mar  4 19:07:00 2004
New Revision: 187

Modified:
   dbi/trunk/lib/DBI/SQL/Nano.pm
Log:
grr, bugfix for ORDER BY in Nano

Modified: dbi/trunk/lib/DBI/SQL/Nano.pm
==============================================================================
--- dbi/trunk/lib/DBI/SQL/Nano.pm       (original)
+++ dbi/trunk/lib/DBI/SQL/Nano.pm       Thu Mar  4 19:07:00 2004
@@ -310,7 +310,7 @@
     if ( $self->{order_clause} ) {
         my( $sort_col, $desc ) = each %{$self->{order_clause}};
         undef $desc unless $desc eq 'DESC';
-        my @sortCols = ( $self->column_nums($table,$sort_col) );
+        my @sortCols = ( $self->column_nums($table,$sort_col,1) );
         my($c, $d, $colNum);
         my $sortFunc = sub {
             my $result;
@@ -399,16 +399,22 @@
    }
 }
 sub column_nums {
-    my($self,$table,$stmt_col_name)[EMAIL PROTECTED];
+    my($self,$table,$stmt_col_name,$find_in_stmt)[EMAIL PROTECTED];
     my %dbd_nums = %{ $table->{col_nums} };
     my @dbd_cols = @{ $table->{col_names} };
     my %stmt_nums;
-    if ($stmt_col_name) {
+    if ($stmt_col_name and !$find_in_stmt) {
         while(my($k,$v)=each %dbd_nums) {
             return $v if uc $k eq uc $stmt_col_name;
         }
         die "No such column '$stmt_col_name'\n";
     }
+    if ($stmt_col_name and $find_in_stmt) {
+        for my $i([EMAIL PROTECTED]>{column_names}}) {
+            return $i if uc $stmt_col_name eq uc $self->{column_names}->[$i];
+        }
+        die "No such column '$stmt_col_name'\n";
+    }
     for my $i(0 .. $#dbd_cols) {
         for my $stmt_col(@{$self->{column_names}}) {
             $stmt_nums{$stmt_col} = $i if uc $dbd_cols[$i] eq uc $stmt_col;

Reply via email to