[Bast-commits] r7677 - in DBIx-Class/0.08/branches/sybase: lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI lib/DBIx/Class/Storage/DBI/Sybase t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Fri Sep 18 06:33:14 GMT 2009


Author: caelum
Date: 2009-09-18 06:33:14 +0000 (Fri, 18 Sep 2009)
New Revision: 7677

Modified:
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm
   DBIx-Class/0.08/branches/sybase/t/746sybase.t
Log:
fix freetds

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm	2009-09-18 02:24:08 UTC (rev 7676)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm	2009-09-18 06:33:14 UTC (rev 7677)
@@ -59,6 +59,9 @@
   return $value;
 }
 
+# for tests
+sub _can_insert_bulk { 0 }
+
 1;
 
 =head1 NAME

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-09-18 02:24:08 UTC (rev 7676)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-09-18 06:33:14 UTC (rev 7677)
@@ -18,6 +18,9 @@
 );
 
 my @also_proxy_to_writer_storage = qw/
+  connect_call_set_auto_cast auto_cast connect_call_blob_setup
+  connect_call_datetime_setup
+
   disconnect _connect_info _sql_maker _sql_maker_opts disable_sth_caching
   auto_savepoint unsafe cursor_class debug debugobj schema
 /;
@@ -124,12 +127,14 @@
 
   $writer_storage->_is_writer_storage(1);
   $writer_storage->connect_info($self->connect_info);
+  $writer_storage->auto_cast($self->auto_cast);
 
   $self->_writer_storage($writer_storage);
 }
 
 for my $method (@also_proxy_to_writer_storage) {
   no strict 'refs';
+  no warnings 'redefine';
 
   my $replaced = __PACKAGE__->can($method);
 
@@ -467,6 +472,9 @@
   $self->_query_end($sql);
 }
 
+# for tests
+sub _can_insert_bulk { 1 }
+
 # XXX this should use the DBD::Sybase bulk API, where possible
 sub insert_bulk {
   my $self = shift;

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm	2009-09-18 02:24:08 UTC (rev 7676)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm	2009-09-18 06:33:14 UTC (rev 7677)
@@ -1339,8 +1339,13 @@
   my %colvalues;
   my $table = $source->from;
   @colvalues{@$cols} = (0..$#$cols);
-  my ($sql, @bind) = $self->sql_maker->insert($table, \%colvalues);
 
+  my ($sql, $bind) = $self->_prep_for_execute (
+    'insert', undef, $source, [\%colvalues]
+  );
+  my @bind = @$bind
+    or croak 'Cannot insert_bulk without support for placeholders';
+
   $self->_query_start( $sql, @bind );
   my $sth = $self->sth($sql);
 
@@ -1371,6 +1376,7 @@
     $placeholder_index++;
   }
   my $rv = eval { $sth->execute_array({ArrayTupleStatus => $tuple_status}) };
+  $sth->finish;
   if (my $err = $@) {
     my $i = 0;
     ++$i while $i <= $#$tuple_status && !ref $tuple_status->[$i];

Modified: DBIx-Class/0.08/branches/sybase/t/746sybase.t
===================================================================
--- DBIx-Class/0.08/branches/sybase/t/746sybase.t	2009-09-18 02:24:08 UTC (rev 7676)
+++ DBIx-Class/0.08/branches/sybase/t/746sybase.t	2009-09-18 06:33:14 UTC (rev 7677)
@@ -204,72 +204,81 @@
     $ping_count-- if $@;
   }
 
+  my $bulk_rs = $schema->resultset('Artist')->search({
+    name => { -like => 'bulk artist %' }
+  });
 
 # test insert_bulk using populate, this should always pass whether or not it
 # does anything Sybase specific or not. Just here to aid debugging.
-  lives_ok {
-    $schema->resultset('Artist')->populate([
-      {
-        name => 'bulk artist 1',
-        charfield => 'foo',
-      },
-      {
-        name => 'bulk artist 2',
-        charfield => 'foo',
-      },
-      {
-        name => 'bulk artist 3',
-        charfield => 'foo',
-      },
-    ]);
-  } 'insert_bulk via populate';
+  SKIP: {
+    skip 'insert_bulk not supported', 4
+      unless $schema->storage->_can_insert_bulk;
 
-  my $bulk_rs = $schema->resultset('Artist')->search({
-    name => { -like => 'bulk artist %' }
-  });
+    lives_ok {
+      $schema->resultset('Artist')->populate([
+        {
+          name => 'bulk artist 1',
+          charfield => 'foo',
+        },
+        {
+          name => 'bulk artist 2',
+          charfield => 'foo',
+        },
+        {
+          name => 'bulk artist 3',
+          charfield => 'foo',
+        },
+      ]);
+    } 'insert_bulk via populate';
 
-  is $bulk_rs->count, 3, 'correct number inserted via insert_bulk';
+    is $bulk_rs->count, 3, 'correct number inserted via insert_bulk';
 
-  is ((grep $_->charfield eq 'foo', $bulk_rs->all), 3,
-    'column set correctly via insert_bulk');
+    is ((grep $_->charfield eq 'foo', $bulk_rs->all), 3,
+      'column set correctly via insert_bulk');
 
-  my %bulk_ids;
-  @bulk_ids{map $_->artistid, $bulk_rs->all} = ();
+    my %bulk_ids;
+    @bulk_ids{map $_->artistid, $bulk_rs->all} = ();
 
-  is ((scalar keys %bulk_ids), 3,
-    'identities generated correctly in insert_bulk');
+    is ((scalar keys %bulk_ids), 3,
+      'identities generated correctly in insert_bulk');
 
-  $bulk_rs->delete;
+    $bulk_rs->delete;
+  }
 
 # now test insert_bulk with IDENTITY_INSERT
-  lives_ok {
-    $schema->resultset('Artist')->populate([
-      {
-        artistid => 2001,
-        name => 'bulk artist 1',
-        charfield => 'foo',
-      },
-      {
-        artistid => 2002,
-        name => 'bulk artist 2',
-        charfield => 'foo',
-      },
-      {
-        artistid => 2003,
-        name => 'bulk artist 3',
-        charfield => 'foo',
-      },
-    ]);
-  } 'insert_bulk with IDENTITY_INSERT via populate';
+  SKIP: {
+    skip 'insert_bulk not supported', 3
+      unless $schema->storage->_can_insert_bulk;
 
-  is $bulk_rs->count, 3,
-    'correct number inserted via insert_bulk with IDENTITY_INSERT';
+    lives_ok {
+      $schema->resultset('Artist')->populate([
+        {
+          artistid => 2001,
+          name => 'bulk artist 1',
+          charfield => 'foo',
+        },
+        {
+          artistid => 2002,
+          name => 'bulk artist 2',
+          charfield => 'foo',
+        },
+        {
+          artistid => 2003,
+          name => 'bulk artist 3',
+          charfield => 'foo',
+        },
+      ]);
+    } 'insert_bulk with IDENTITY_INSERT via populate';
 
-  is ((grep $_->charfield eq 'foo', $bulk_rs->all), 3,
-    'column set correctly via insert_bulk with IDENTITY_INSERT');
+    is $bulk_rs->count, 3,
+      'correct number inserted via insert_bulk with IDENTITY_INSERT';
 
-  $bulk_rs->delete;
+    is ((grep $_->charfield eq 'foo', $bulk_rs->all), 3,
+      'column set correctly via insert_bulk with IDENTITY_INSERT');
 
+    $bulk_rs->delete;
+  }
+
 # test correlated subquery
   my $subq = $schema->resultset('Artist')->search({ artistid => { '>' => 3 } })
     ->get_column('artistid')
@@ -281,7 +290,7 @@
 
 # mostly stolen from the blob stuff Nniuq wrote for t/73oracle.t
   SKIP: {
-    skip 'TEXT/IMAGE support does not work with FreeTDS', 16
+    skip 'TEXT/IMAGE support does not work with FreeTDS', 15
       if $schema->storage->using_freetds;
 
     my $dbh = $schema->storage->_dbh;
@@ -401,10 +410,7 @@
   });
 
 # test insert transaction when there's an active cursor
-  SKIP: {
-    skip 'not testing insert with active cursor if using ::NoBindVars', 1
-      if $storage_type =~ /NoBindVars/i;
-
+  {
     my $artist_rs = $schema->resultset('Artist');
     $artist_rs->first;
     lives_ok {




More information about the Bast-commits mailing list