eol adjustments
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / SQLAHacks.pm
index 02f28cc..b38dbf5 100644 (file)
@@ -76,7 +76,7 @@ sub _RowNumberOver {
   my ($self, $sql, $order, $rows, $offset ) = @_;
 
   $offset += 1;
-  my $last = $rows + $offset;
+  my $last = $rows + $offset - 1;
   my ( $order_by ) = $self->_order_by( $order );
 
   $sql = <<"SQL";
@@ -105,8 +105,10 @@ sub _find_syntax {
   # RowNumberOver is still needed here (should be part of SQLA) leave the 
   # code in place
   my $dbhname = blessed($syntax) ? $syntax->{Driver}{Name} : $syntax;
-  if(ref($self) && $dbhname && $dbhname eq 'DB2') {
-    return 'RowNumberOver';
+  if(ref($self) && $dbhname) {
+    if ($dbhname eq 'DB2') {
+      return 'RowNumberOver';
+    }
   }
   
   $self->{_cached_syntax} ||= $self->SUPER::_find_syntax($syntax);
@@ -191,20 +193,20 @@ sub _recurse_fields {
       if ($func eq 'distinct') {
         my $_fields = $fields->{$func};
         if (ref $_fields eq 'ARRAY' && @{$_fields} > 1) {
-          croak "Unsupported syntax, please use " . 
-              "{ group_by => [ qw/" . (join ' ', @$_fields) . "/ ] }" .
-              " or " .
-              "{ select => [ qw/" . (join ' ', @$_fields) . "/ ], distinct => 1 }";
+          croak (
+            'The select => { distinct => ... } syntax is not supported for multiple columns.'
+           .' Instead please use { group_by => [ qw/' . (join ' ', @$_fields) . '/ ] }'
+           .' or { select => [ qw/' . (join ' ', @$_fields) . '/ ], distinct => 1 }'
+          );
         }
         else {
           $_fields = @{$_fields}[0] if ref $_fields eq 'ARRAY';
-          carp "This syntax will be deprecated in 09, please use " . 
-               "{ group_by => '${_fields}' }" . 
-               " or " .
-               "{ select => '${_fields}', distinct => 1 }";
+          carp (
+            'The select => { distinct => ... } syntax will be deprecated in DBIC version 0.09,'
+           ." please use { group_by => '${_fields}' } or { select => '${_fields}', distinct => 1 }"
+          );
         }
       }
-      
       return $self->_sqlcase($func)
         .'( '.$self->_recurse_fields($fields->{$func}).' )';
     }
@@ -338,8 +340,11 @@ sub _recurse_from {
 
 sub _fold_sqlbind {
   my ($self, $sqlbind) = @_;
-  my $sql = shift @$$sqlbind;
-  push @{$self->{from_bind}}, @$$sqlbind;
+
+  my @sqlbind = @$$sqlbind; # copy
+  my $sql = shift @sqlbind;
+  push @{$self->{from_bind}}, @sqlbind;
+
   return $sql;
 }