Merge 'trunk' into 'arbitrary_op_nesting'
Peter Rabbitson [Sun, 7 Mar 2010 22:42:04 +0000 (22:42 +0000)]
r8568@Thesaurus (orig r8555):  ribasushi | 2010-02-05 17:31:39 +0100
Release 1.61
r8836@Thesaurus (orig r8823):  rabbit | 2010-02-27 00:25:14 +0100
Lose a couple of oddball dependencies (while moronizing the tests a bit)
r8837@Thesaurus (orig r8824):  rabbit | 2010-02-27 00:34:45 +0100
Slightly change the license wording (to satisfy the M::I license guesser) while keeping the former verbosity
r8902@Thesaurus (orig r8889):  semifor | 2010-03-05 17:53:59 +0100
fixed open outer parens in a multi-line literal

r8947@Thesaurus (orig r8934):  rabbit | 2010-03-07 22:51:20 +0100
Factor out insert returning generator

Changes
Makefile.PL
lib/SQL/Abstract.pm
lib/SQL/Abstract/Test.pm
t/04modifiers.t
t/05in_between.t

diff --git a/Changes b/Changes
index c6f9c64..0cfb830 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for SQL::Abstract
 
+    - fixed open outer parens for a multi-line literal
+
+revision 1.61  2010-02-05 16:28 (UTC)
+----------------------------
     - Allow INSERT to take additional attributes
     - Support for INSERT ... RETURNING
     - Another iteration of SQL::Abstract::Test fixes and improvements
index 801726e..b9162bf 100644 (file)
@@ -10,15 +10,14 @@ author 'Nathan Wiger <nate@wiger.org>';
 
 all_from 'lib/SQL/Abstract.pm';
 
-requires "List::Util"   => 0;
-requires "Scalar::Util" => 0;
+requires 'List::Util'   => 0;
+requires 'Scalar::Util' => 0;
+requires 'Storable'     => 0;
 
 test_requires "Test::Builder"   => 0;
-test_requires "Test::Deep"      => 0;
 test_requires "Test::More"      => 0;
 test_requires "Test::Exception" => 0;
 test_requires "Test::Warn"      => 0;
-test_requires "Clone"           => 0.31;
 
 tests_recursive 't';
 
index c1da181..722743a 100644 (file)
@@ -15,7 +15,7 @@ use Scalar::Util qw/blessed/;
 # GLOBALS
 #======================================================================
 
-our $VERSION  = '1.60';
+our $VERSION  = '1.61';
 
 # This would confuse some packagers
 #$VERSION      = eval $VERSION; # numify for warning-free dev releases
@@ -118,18 +118,24 @@ sub insert {
   my ($sql, @bind) = $self->$method($data);
   $sql = join " ", $self->_sqlcase('insert into'), $table, $sql;
 
-  if (my $fields = $options->{returning}) {
-    my $f = $self->_SWITCH_refkind($fields, {
-      ARRAYREF     => sub {join ', ', map { $self->_quote($_) } @$fields;},
-      SCALAR       => sub {$self->_quote($fields)},
-      SCALARREF    => sub {$$fields},
-    });
-    $sql .= join " ", $self->_sqlcase(' returning'), $f;
+  if (my $ret = $options->{returning}) {
+    $sql .= $self->_insert_returning ($ret);
   }
 
   return wantarray ? ($sql, @bind) : $sql;
 }
 
+sub _insert_returning {
+  my ($self, $fields) = @_;
+
+  my $f = $self->_SWITCH_refkind($fields, {
+    ARRAYREF     => sub {join ', ', map { $self->_quote($_) } @$fields;},
+    SCALAR       => sub {$self->_quote($fields)},
+    SCALARREF    => sub {$$fields},
+  });
+  return join (' ', $self->_sqlcase(' returning'), $f);
+}
+
 sub _insert_HASHREF { # explicit list of fields and then values
   my ($self, $data) = @_;
 
@@ -928,7 +934,7 @@ sub _where_field_IN {
 # adding them back in the corresponding method
 sub _open_outer_paren {
   my ($self, $sql) = @_;
-  $sql = $1 while $sql =~ /^ \s* \( (.*) \) \s* $/x;
+  $sql = $1 while $sql =~ /^ \s* \( (.*) \) \s* $/xs;
   return $sql;
 }
 
@@ -2685,9 +2691,9 @@ how to create queries.
 
 =head1 LICENSE
 
-This module is free software; you may copy this under the terms of
-the GNU General Public License, or the Artistic License, copies of
-which should have accompanied your Perl kit.
+This module is free software; you may copy this under the same
+terms as perl itself (either the GNU General Public License or
+the Artistic License)
 
 =cut
 
index 8951e36..16450b7 100644 (file)
@@ -6,7 +6,6 @@ use base qw/Test::Builder::Module Exporter/;
 use Data::Dumper;
 use Carp;
 use Test::Builder;
-use Test::Deep qw(eq_deeply);
 
 our @EXPORT_OK = qw/&is_same_sql_bind &is_same_sql &is_same_bind
                     &eq_sql_bind &eq_sql &eq_bind 
@@ -177,7 +176,10 @@ sub eq_sql_bind {
 sub eq_bind {
   my ($bind_ref1, $bind_ref2) = @_;
 
-  return eq_deeply($bind_ref1, $bind_ref2);
+  local $Data::Dumper::Useqq = 1;
+  local $Data::Dumper::Sortkeys = 1;
+
+  return Dumper($bind_ref1) eq Dumper($bind_ref2);
 }
 
 sub eq_sql {
index cce81f2..355ef67 100644 (file)
@@ -7,8 +7,8 @@ use Test::Exception;
 use SQL::Abstract::Test import => ['is_same_sql_bind'];
 
 use Data::Dumper;
+use Storable qw/dclone/;
 use SQL::Abstract;
-use Clone;
 
 =begin
 Test -and -or and -nest modifiers, assuming the following:
@@ -384,7 +384,7 @@ for my $case (@and_or_tests) {
     local $SIG{__WARN__} = sub { push @w, @_ };
 
     my $sql = SQL::Abstract->new ($case->{args} || {});
-    my $where_copy = Clone::clone ($case->{where});
+    my $where_copy = dclone($case->{where});
 
     lives_ok (sub { 
       my ($stmt, @bind) = $sql->where($case->{where});
index bf32375..ff6b738 100644 (file)
@@ -115,6 +115,16 @@ my @in_between_tests = (
   {
     parenthesis_significant => 1,
     where => {
+      status => { -in => \"(SELECT status_codes\nFROM states)" },
+    },
+    # failed to open outer parens on a multi-line query in 1.61 (semifor)
+    stmt => " WHERE ( status IN ( SELECT status_codes FROM states )) ",
+    bind => [],
+    test => '-in multi-line subquery test',
+  },
+  {
+    parenthesis_significant => 1,
+    where => {
       customer => { -in => \[
         'SELECT cust_id FROM cust WHERE balance > ?',
         2000,