release 1.74
[dbsrgits/SQL-Abstract.git] / lib / SQL / Abstract.pm
index 9b29b5e..3940881 100644 (file)
@@ -15,7 +15,7 @@ use Scalar::Util ();
 # GLOBALS
 #======================================================================
 
-our $VERSION  = '1.73';
+our $VERSION  = '1.74';
 
 # This would confuse some packagers
 $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
@@ -1150,24 +1150,16 @@ sub _order_by_chunks {
     SCALARREF => sub {$$arg}, # literal SQL, no quoting
 
     HASHREF   => sub {
-      return () unless %$arg;
-
-      my ($direction, $nulls, $val);
-      foreach my $key (keys %$arg) {
-        if ( $key =~ /^-(desc|asc)/i ) {
-          puke "hash passed to _order_by must have exactly one of -desc or -asc"
-              if defined $direction;
-          $direction = $1;
-          $val = $arg->{$key};
-        } elsif ($key =~ /^-nulls$/i)  {
-          $nulls = $arg->{$key};
-          puke "invalid value for -nulls" unless $nulls =~ /^(?:first|last)$/i;
-        } else {
-          puke "invalid key in hash passed to _order_by";
-        }
+      # get first pair in hash
+      my ($key, $val, @rest) = %$arg;
+
+      return () unless $key;
+
+      if ( @rest or not $key =~ /^-(desc|asc)/i ) {
+        puke "hash passed to _order_by must have exactly one key (-desc or -asc)";
       }
-      puke "hash passed to _order_by must have exactly one of -desc or -asc"
-          unless defined $direction;
+
+      my $direction = $1;
 
       my @ret;
       for my $c ($self->_order_by_chunks ($val)) {
@@ -1182,9 +1174,7 @@ sub _order_by_chunks {
           },
         });
 
-        $sql .= ' ' . $self->_sqlcase($direction);
-        $sql .= ' ' . $self->_sqlcase("nulls $nulls")
-            if defined $nulls;
+        $sql = $sql . ' ' . $self->_sqlcase($direction);
 
         push @ret, [ $sql, @bind];
       }
@@ -1520,7 +1510,7 @@ SQL::Abstract - Generate SQL from Perl data structures
 
     my $sql = SQL::Abstract->new;
 
-    my($stmt, @bind) = $sql->select($table, \@fields, \%where, \@order);
+    my($stmt, @bind) = $sql->select($source, \@fields, \%where, \@order);
 
     my($stmt, @bind) = $sql->insert($table, \%fieldvals || \@values);
 
@@ -1948,8 +1938,8 @@ the source.
 The argument can be either an arrayref (interpreted as a list
 of field names, will be joined by commas and quoted), or a
 plain scalar (literal SQL, not quoted).
-Please observe that this API is not as flexible as for
-the first argument C<$table>, for backwards compatibility reasons.
+Please observe that this API is not as flexible as that of
+the first argument C<$source>, for backwards compatibility reasons.
 
 =item $where
 
@@ -2631,7 +2621,6 @@ script.
 
 Some functions take an order by clause. This can either be a scalar (just a
 column name,) a hash of C<< { -desc => 'col' } >> or C<< { -asc => 'col' } >>,
-optionally with C<< -nulls => 'first' >> or C<< -nulls => 'last' >>,
 or an array of either of the two previous forms. Examples:
 
                Given            |         Will Generate
@@ -2647,20 +2636,10 @@ or an array of either of the two previous forms. Examples:
                                 |
     {-desc => 'colB'}           | ORDER BY colB DESC
                                 |
-    {                           |
-      -asc => 'colA',           | ORDER BY colA ASC NULLS LAST
-      -nulls => 'last',         |
-    }                           |
-                                |
     ['colA', {-asc => 'colB'}]  | ORDER BY colA, colB ASC
                                 |
     { -asc => [qw/colA colB/] } | ORDER BY colA ASC, colB ASC
                                 |
-    {                           |
-      -asc => [qw/colA colB/]   | ORDER BY colA ASC NULLS FIRST,
-      -nulls => 'first'         |          colB ASC NULLS FIRST
-    }                           |
-                                |
     [                           |
       { -asc => 'colA' },       | ORDER BY colA ASC, colB DESC,
       { -desc => [qw/colB/],    |          colC ASC, colD ASC