[Bast-commits] r7741 - in DBIx-Class/0.08/branches/sybase_bulkinsert_support: lib/DBIx/Class lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Tue Sep 29 02:25:56 GMT 2009


Author: caelum
Date: 2009-09-29 02:25:55 +0000 (Tue, 29 Sep 2009)
New Revision: 7741

Modified:
   DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/ResultSet.pm
   DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Replicated.pm
   DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Sybase.pm
   DBIx-Class/0.08/branches/sybase_bulkinsert_support/t/100populate.t
Log:
removed some dead code, added fix and test for _execute_array_empty

Modified: DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/ResultSet.pm	2009-09-28 21:26:06 UTC (rev 7740)
+++ DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/ResultSet.pm	2009-09-29 02:25:55 UTC (rev 7741)
@@ -1796,7 +1796,10 @@
   } else {
     my ($first, @rest) = @$data;
 
-    my @names = grep {!ref $first->{$_}} keys %$first;
+    my @names = grep {
+      (not ref $first->{$_}) || (ref $first->{$_} eq 'SCALAR')
+    } keys %$first;
+
     my @rels = grep { $self->result_source->has_relationship($_) } keys %$first;
     my @pks = $self->result_source->primary_columns;
 
@@ -2796,10 +2799,7 @@
       : (
           ( delete $attrs->{columns} )
             ||
-          $source->storage->order_select_columns(
-              $source,
-              [ $source->columns ],
-          )
+          $source->columns
         )
     ;
 

Modified: DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Replicated.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Replicated.pm	2009-09-28 21:26:06 UTC (rev 7740)
+++ DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Replicated.pm	2009-09-29 02:25:55 UTC (rev 7741)
@@ -325,7 +325,6 @@
     _count_select
     _subq_count_select
     _subq_update_delete
-    order_select_columns
     svp_rollback
     svp_begin
     svp_release

Modified: DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-09-28 21:26:06 UTC (rev 7740)
+++ DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-09-29 02:25:55 UTC (rev 7741)
@@ -449,6 +449,8 @@
 # it is originally put by _remove_blob_cols .)
   my %blobs_to_empty = map { ($_ => delete $fields->{$_}) } keys %$blob_cols;
 
+# We can't only update NULL blobs, because blobs cannot be in the WHERE clause.
+
   $self->next::method($source, \%blobs_to_empty, $where, @rest);
 
 # Now update the blobs before the other columns in case the update of other

Modified: DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI.pm	2009-09-28 21:26:06 UTC (rev 7740)
+++ DBIx-Class/0.08/branches/sybase_bulkinsert_support/lib/DBIx/Class/Storage/DBI.pm	2009-09-29 02:25:55 UTC (rev 7741)
@@ -1335,7 +1335,7 @@
 ## scalar refs, or at least, all the same type as the first set, the statement is
 ## only prepped once.
 sub insert_bulk {
-  my ($self, $source, $cols, $data, $sth_attr) = @_;
+  my ($self, $source, $cols, $data) = @_;
 
 # redispatch to insert_bulk method of storage we reblessed into, if necessary
   if (not $self->_driver_determined) {
@@ -1374,7 +1374,7 @@
   }
 
   $self->_query_start( $sql, @bind );
-  my $sth = $self->sth($sql, 'insert', $sth_attr);
+  my $sth = $self->sth($sql);
 
   my $rv = do {
     if ($empty_bind) {
@@ -2053,27 +2053,6 @@
   return @pcols ? \@pcols : [ 1 ];
 }
 
-=head2 order_select_columns
-
-=over 4
-
-=item Arguments: $source, \@columns
-
-=back
-
-Returns an ordered list of column names to be used in a SELECT statement. By
-default simply returns the list that was passed in.
-
-This may be overridden in a specific storage when there are requirements such as
-moving BLOB columns to the end of the SELECT list.
-
-=cut
-
-sub order_select_columns {
-  #my ($self, $source, $columns) = @_;
-  return @{$_[2]};
-}
-
 sub source_bind_attributes {
   my ($self, $source) = @_;
 
@@ -2132,15 +2111,12 @@
 =cut
 
 sub _dbh_sth {
-  my ($self, $dbh, $sql, $op, $sth_attr) = @_;
-# $op is ignored right now
+  my ($self, $dbh, $sql) = @_;
 
-  $sth_attr ||= {};
-
   # 3 is the if_active parameter which avoids active sth re-use
   my $sth = $self->disable_sth_caching
-    ? $dbh->prepare($sql, $sth_attr)
-    : $dbh->prepare_cached($sql, $sth_attr, 3);
+    ? $dbh->prepare($sql)
+    : $dbh->prepare_cached($sql, {}, 3);
 
   # XXX You would think RaiseError would make this impossible,
   #  but apparently that's not true :(
@@ -2150,8 +2126,8 @@
 }
 
 sub sth {
-  my ($self, $sql, $op, $sth_attr) = @_;
-  $self->dbh_do('_dbh_sth', $sql, $op, $sth_attr);  # retry over disconnects
+  my ($self, $sql) = @_;
+  $self->dbh_do('_dbh_sth', $sql);  # retry over disconnects
 }
 
 sub _dbh_columns_info_for {

Modified: DBIx-Class/0.08/branches/sybase_bulkinsert_support/t/100populate.t
===================================================================
--- DBIx-Class/0.08/branches/sybase_bulkinsert_support/t/100populate.t	2009-09-28 21:26:06 UTC (rev 7740)
+++ DBIx-Class/0.08/branches/sybase_bulkinsert_support/t/100populate.t	2009-09-29 02:25:55 UTC (rev 7741)
@@ -6,7 +6,7 @@
 use lib qw(t/lib);
 use DBICTest;
 
-plan tests => 23;
+plan tests => 24;
 
 my $schema = DBICTest->init_schema();
 
@@ -116,3 +116,19 @@
 is($link7->url, undef, 'Link 7 url');
 is($link7->title, 'gtitle', 'Link 7 title');
 
+# test _execute_array_empty (insert_bulk with all literal sql)
+my $rs = $schema->resultset('Artist');
+$rs->delete;
+$rs->populate([
+    (+{
+        name => \"'DT'",
+        rank => \500,
+        charfield => \"'mtfnpy'",
+    }) x 5
+]);
+
+is((grep {
+  $_->name eq 'DT' &&
+  $_->rank == 500  &&
+  $_->charfield eq 'mtfnpy'
+} $rs->all), 5, 'populate with all literal SQL');




More information about the Bast-commits mailing list