[Bast-commits] r7047 - in DBIx-Class/0.08/branches/reduce_pings: lib/DBIx/Class lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI lib/DBIx/Class/Storage/DBI/ODBC lib/DBIx/Class/Storage/DBI/Oracle t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Tue Jul 14 13:09:48 GMT 2009


Author: caelum
Date: 2009-07-14 13:09:47 +0000 (Tue, 14 Jul 2009)
New Revision: 7047

Modified:
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Schema.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Pg.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Sybase.pm
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/mysql.pm
   DBIx-Class/0.08/branches/reduce_pings/t/746mssql.t
Log:
substantially reduced ping count, dynamic cursors support for mssql through odbc

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Schema.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Schema.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -42,7 +42,7 @@
     $dsn,
     $user,
     $password,
-    { AutoCommit => 0 },
+    { AutoCommit => 1 },
   );
 
   my $schema2 = Library::Schema->connect($coderef_returning_dbh);

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -4,9 +4,98 @@
 
 use base qw/DBIx::Class::Storage::DBI::MSSQL/;
 use mro 'c3';
-
+use Carp::Clan qw/^DBIx::Class/;
 use List::Util();
 
+__PACKAGE__->mk_group_accessors(simple => qw/
+  _scope_identity _using_dynamic_cursors
+/);
+
+=head1 NAME
+
+DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server - Support specific
+to Microsoft SQL Server over ODBC
+
+=head1 DESCRIPTION
+
+This class implements support specific to Microsoft SQL Server over ODBC,
+including auto-increment primary keys and SQL::Abstract::Limit dialect.  It
+is loaded automatically by by DBIx::Class::Storage::DBI::ODBC when it
+detects a MSSQL back-end.
+
+=head1 IMPLEMENTATION NOTES
+
+Microsoft SQL Server supports three methods of retrieving the C<IDENTITY>
+value for inserted row: C<IDENT_CURRENT>, C<@@IDENTITY>, and C<SCOPE_IDENTITY()>.
+C<SCOPE_IDENTITY()> is used here because it is the safest.  However, it must
+be called is the same execute statement, not just the same connection.
+
+So, this implementation appends a C<SELECT SCOPE_IDENTITY()> statement
+onto each C<INSERT> to accommodate that requirement.
+
+If you use dynamic cursors with C<< odbc_cursortype => 2 >> or
+L</on_connect_call_use_dynamic_cursors> then the less accurate
+C<SELECT @@IDENTITY> is used instead.
+
+=head1 MULTIPLE ACTIVE STATEMENTS
+
+The following options are alternative ways to enable concurrent executing
+statement support. Each has its own advantages and drawbacks.
+
+=head2 connect_call_use_dynamic_cursors
+
+Use as:
+
+  on_connect_call => 'use_dynamic_cursors'
+
+in your L<DBIx::Class::Storage::DBI/connect_info> as one way to enable multiple
+concurrent statements.
+
+Will add C<< odbc_cursortype => 2 >> to your DBI connection attributes. See
+L<DBD::ODBC/odbc_cursortype> for more information.
+
+This will not work with CODE ref connect_info's and will do nothing if you set
+C<odbc_cursortype> yourself.
+
+B<WARNING:> this will break C<SCOPE_IDENTITY()>, and C<SELECT @@IDENTITY> will
+be used instead, which on SQL Server 2005 and later will return erroneous
+results on tables which have an on insert trigger that inserts into another
+table with an C<IDENTITY> column.
+
+=cut
+
+sub connect_call_use_dynamic_cursors {
+  my $self = shift;
+
+  if (ref($self->_dbi_connect_info->[0]) eq 'CODE') {
+    croak 'cannot set DBI attributes on CODE ref connect_infos';
+  }
+
+  my $dbi_attrs = $self->_dbi_connect_info->[-1];
+  $dbi_attrs ||= {};
+
+  if (not exists $dbi_attrs->{odbc_cursortype}) {
+    # turn on support for multiple concurrent statements, unless overridden
+    $self->_dbi_connect_info->[-1] = { %$dbi_attrs, odbc_cursortype => 2 };
+    # will take effect next connection
+    $self->disconnect;
+    $self->_using_dynamic_cursors(1);
+  }
+}
+
+sub _rebless {
+  no warnings 'uninitialized';
+  my $self = shift;
+
+  if (ref($self->_dbi_connect_info->[0]) ne 'CODE' &&
+      $self->_dbi_connect_info->[-1]{odbc_cursortype} == 2) {
+    $self->_using_dynamic_cursors(1);
+    return;
+  }
+
+  $self->_using_dynamic_cursors(0);
+}
+
 sub insert_bulk {
   my $self = shift;
   my ($source, $cols, $data) = @_;
@@ -23,14 +112,14 @@
 
   if ($identity_insert) {
     my $table = $source->from;
-    $self->dbh->do("SET IDENTITY_INSERT $table ON");
+    $self->_get_dbh->do("SET IDENTITY_INSERT $table ON");
   }
 
   $self->next::method(@_);
 
   if ($identity_insert) {
     my $table = $source->from;
-    $self->dbh->do("SET IDENTITY_INSERT $table OFF");
+    $self->_get_dbh->do("SET IDENTITY_INSERT $table OFF");
   }
 }
 
@@ -62,48 +151,31 @@
 
     my ($rv, $sth, @bind) = $self->dbh_do($self->can('_dbh_execute'), @_);
     if ($op eq 'insert') {
-      $self->{_scope_identity} = $sth->fetchrow_array;
+      my ($identity) = $sth->fetchrow_array;
       $sth->finish;
+
+      if ((not defined $identity) && $self->_using_dynamic_cursors) {
+        ($identity) = $self->_dbh->selectrow_array('select @@identity');
+      }
+
+      $self->_scope_identity($identity);
     }
 
     return wantarray ? ($rv, $sth, @bind) : $rv;
 }
 
-sub last_insert_id { shift->{_scope_identity} }
+sub last_insert_id { shift->_scope_identity() }
 
 1;
 
-__END__
+=head1 AUTHOR
 
-=head1 NAME
+See L<DBIx::Class/CONTRIBUTORS>.
 
-DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server - Support specific
-to Microsoft SQL Server over ODBC
-
-=head1 DESCRIPTION
-
-This class implements support specific to Microsoft SQL Server over ODBC,
-including auto-increment primary keys and SQL::Abstract::Limit dialect.  It
-is loaded automatically by by DBIx::Class::Storage::DBI::ODBC when it
-detects a MSSQL back-end.
-
-=head1 IMPLEMENTATION NOTES
-
-Microsoft SQL Server supports three methods of retrieving the IDENTITY
-value for inserted row: IDENT_CURRENT, @@IDENTITY, and SCOPE_IDENTITY().
-SCOPE_IDENTITY is used here because it is the safest.  However, it must
-be called is the same execute statement, not just the same connection.
-
-So, this implementation appends a SELECT SCOPE_IDENTITY() statement
-onto each INSERT to accommodate that requirement.
-
-=head1 AUTHORS
-
-Marc Mims C<< <marc at questright.com> >>
-
 =head1 LICENSE
 
 You may distribute this code under the same terms as Perl itself.
 
 =cut
+
 # vim: sw=2 sts=2

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/ODBC.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -8,7 +8,8 @@
 sub _rebless {
     my ($self) = @_;
 
-    my $dbtype = eval { $self->dbh->get_info(17) };
+    my $dbtype = eval { $self->_get_dbh->get_info(17) };
+
     unless ( $@ ) {
         # Translate the backend name into a perl identifier
         $dbtype =~ s/\W/_/gi;

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -79,7 +79,7 @@
 
 sub _sequence_fetch {
   my ( $self, $type, $seq ) = @_;
-  my ($id) = $self->dbh->selectrow_array("SELECT ${seq}.${type} FROM DUAL");
+  my ($id) = $self->_get_dbh->selectrow_array("SELECT ${seq}.${type} FROM DUAL");
   return $id;
 }
 
@@ -195,7 +195,7 @@
 
 sub connect_call_datetime_setup {
   my $self = shift;
-  my $dbh  = $self->dbh;
+  my $dbh  = $self->_get_dbh;
 
   my $date_format = $ENV{NLS_DATE_FORMAT} ||= 'YYYY-MM-DD HH24:MI:SS';
   my $timestamp_format = $ENV{NLS_TIMESTAMP_FORMAT} ||=
@@ -211,7 +211,7 @@
 sub _svp_begin {
     my ($self, $name) = @_;
  
-    $self->dbh->do("SAVEPOINT $name");
+    $self->_get_dbh->do("SAVEPOINT $name");
 }
 
 =head2 source_bind_attributes
@@ -263,7 +263,7 @@
 sub _svp_rollback {
     my ($self, $name) = @_;
 
-    $self->dbh->do("ROLLBACK TO SAVEPOINT $name")
+    $self->_get_dbh->do("ROLLBACK TO SAVEPOINT $name")
 }
 
 =head1 AUTHORS

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Oracle.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -9,7 +9,7 @@
 sub _rebless {
     my ($self) = @_;
 
-    my $version = eval { $self->dbh->get_info(18); };
+    my $version = eval { $self->_get_dbh->get_info(18); };
 
     if ( !$@ ) {
         my ($major, $minor, $patchlevel) = split(/\./, $version);

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Pg.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Pg.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Pg.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -15,7 +15,7 @@
 sub with_deferred_fk_checks {
   my ($self, $sub) = @_;
 
-  $self->dbh->do('SET CONSTRAINTS ALL DEFERRED');
+  $self->_get_dbh->do('SET CONSTRAINTS ALL DEFERRED');
   $sub->();
 }
 
@@ -82,26 +82,26 @@
 
 sub _sequence_fetch {
   my ( $self, $type, $seq ) = @_;
-  my ($id) = $self->dbh->selectrow_array("SELECT nextval('${seq}')");
+  my ($id) = $self->_get_dbh->selectrow_array("SELECT nextval('${seq}')");
   return $id;
 }
 
 sub _svp_begin {
     my ($self, $name) = @_;
 
-    $self->dbh->pg_savepoint($name);
+    $self->_get_dbh->pg_savepoint($name);
 }
 
 sub _svp_release {
     my ($self, $name) = @_;
 
-    $self->dbh->pg_release($name);
+    $self->_get_dbh->pg_release($name);
 }
 
 sub _svp_rollback {
     my ($self, $name) = @_;
 
-    $self->dbh->pg_rollback_to($name);
+    $self->_get_dbh->pg_rollback_to($name);
 }
 
 1;

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -12,7 +12,11 @@
 sub _rebless {
     my $self = shift;
 
-    my $dbtype = eval { @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] };
+    my $dbtype = eval {
+      @{$self->_get_dbh
+        ->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})
+      }[2]
+    };
     unless ( $@ ) {
         $dbtype =~ s/\W/_/gi;
         my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/mysql.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/mysql.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI/mysql.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -32,28 +32,28 @@
 sub _svp_begin {
     my ($self, $name) = @_;
 
-    $self->dbh->do("SAVEPOINT $name");
+    $self->_get_dbh->do("SAVEPOINT $name");
 }
 
 sub _svp_release {
     my ($self, $name) = @_;
 
-    $self->dbh->do("RELEASE SAVEPOINT $name");
+    $self->_get_dbh->do("RELEASE SAVEPOINT $name");
 }
 
 sub _svp_rollback {
     my ($self, $name) = @_;
 
-    $self->dbh->do("ROLLBACK TO SAVEPOINT $name")
+    $self->_get_dbh->do("ROLLBACK TO SAVEPOINT $name")
 }
 
 sub is_replicating {
-    my $status = shift->dbh->selectrow_hashref('show slave status');
+    my $status = shift->_get_dbh->selectrow_hashref('show slave status');
     return ($status->{Slave_IO_Running} eq 'Yes') && ($status->{Slave_SQL_Running} eq 'Yes');
 }
 
 sub lag_behind_master {
-    return shift->dbh->selectrow_hashref('show slave status')->{Seconds_Behind_Master};
+    return shift->_get_dbh->selectrow_hashref('show slave status')->{Seconds_Behind_Master};
 }
 
 # MySql can not do subquery update/deletes, only way is slow per-row operations.

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm	2009-07-14 13:09:47 UTC (rev 7047)
@@ -437,12 +437,21 @@
     }
   }
 
-  %attrs = () if (ref $args[0] eq 'CODE');  # _connect() never looks past $args[0] in this case
+  if (ref $args[0] eq 'CODE') {
+    # _connect() never looks past $args[0] in this case
+    %attrs = ()
+  } else {
+    %attrs = (%{ $self->_dbi_connect_attributes }, %attrs);
+  }
 
   $self->_dbi_connect_info([@args, keys %attrs ? \%attrs : ()]);
   $self->_connect_info;
 }
 
+sub _dbi_connect_attributes {
+  return { AutoCommit => 1 };
+}
+
 =head2 on_connect_do
 
 This method is deprecated in favour of setting via L</connect_info>.
@@ -621,7 +630,7 @@
 sub disconnect {
   my ($self) = @_;
 
-  if( $self->connected ) {
+  if( $self->_dbh ) {
     my @actions;
 
     push @actions, ( $self->on_disconnect_call || () );
@@ -724,10 +733,24 @@
   return $self->_dbh;
 }
 
+sub _get_dbh {
+  my $self = shift;
+
+  if (not $self->_dbh) {
+    $self->_populate_dbh;
+  }
+  return $self->_dbh;
+}
+
 sub _sql_maker_args {
     my ($self) = @_;
 
-    return ( bindtype=>'columns', array_datatypes => 1, limit_dialect => $self->dbh, %{$self->_sql_maker_opts} );
+    return (
+      bindtype=>'columns',
+      array_datatypes => 1,
+      limit_dialect => $self->_get_dbh,
+      %{$self->_sql_maker_opts}
+    );
 }
 
 sub sql_maker {
@@ -744,6 +767,7 @@
 
 sub _populate_dbh {
   my ($self) = @_;
+
   my @info = @{$self->_dbi_connect_info || []};
   $self->_dbh($self->_connect(@info));
 
@@ -756,6 +780,11 @@
   #  there is no transaction in progress by definition
   $self->{transaction_depth} = $self->_dbh_autocommit ? 0 : 1;
 
+  $self->_run_connection_actions unless $self->{_in_determine_driver};
+}
+
+sub _run_connection_actions {
+  my $self = shift;
   my @actions;
 
   push @actions, ( $self->on_connect_call || () );
@@ -769,6 +798,8 @@
 
   if (ref $self eq 'DBIx::Class::Storage::DBI') {
     my $driver;
+    my $started_unconnected = 0;
+    local $self->{_in_determine_driver} = 1;
 
     if ($self->_dbh) { # we are connected
       $driver = $self->_dbh->{Driver}{Name};
@@ -776,6 +807,7 @@
       # try to use dsn to not require being connected, the driver may still
       # force a connection in _rebless to determine version
       ($driver) = $self->_dbi_connect_info->[0] =~ /dbi:([^:]+):/i;
+      $started_unconnected = 1;
     }
 
     my $storage_class = "DBIx::Class::Storage::DBI::${driver}";
@@ -784,6 +816,8 @@
       bless $self, $storage_class;
       $self->_rebless();
     }
+
+    $self->_run_connection_actions if $started_unconnected;
   }
 }
 
@@ -983,14 +1017,13 @@
 
 sub txn_begin {
   my $self = shift;
-  $self->ensure_connected();
   if($self->{transaction_depth} == 0) {
     $self->debugobj->txn_begin()
       if $self->debug;
     # this isn't ->_dbh-> because
     #  we should reconnect on begin_work
     #  for AutoCommit users
-    $self->dbh->begin_work;
+    $self->dbh_do(sub { $_[1]->begin_work });
   } elsif ($self->auto_savepoint) {
     $self->svp_begin;
   }
@@ -1146,18 +1179,23 @@
 sub insert {
   my ($self, $source, $to_insert) = @_;
 
+  $self->_determine_driver;
+
   my $ident = $source->from;
   my $bind_attributes = $self->source_bind_attributes($source);
 
   my $updated_cols = {};
 
-  $self->ensure_connected;
   foreach my $col ( $source->columns ) {
     if ( !defined $to_insert->{$col} ) {
       my $col_info = $source->column_info($col);
 
       if ( $col_info->{auto_nextval} ) {
-        $updated_cols->{$col} = $to_insert->{$col} = $self->_sequence_fetch( 'nextval', $col_info->{sequence} || $self->_dbh_get_autoinc_seq($self->dbh, $source) );
+        $updated_cols->{$col} = $to_insert->{$col} = $self->_sequence_fetch(
+          'nextval',
+          $col_info->{sequence} ||
+            $self->_dbh_get_autoinc_seq($self->_get_dbh, $source)
+        );
       }
     }
   }
@@ -1178,6 +1216,8 @@
   @colvalues{@$cols} = (0..$#$cols);
   my ($sql, @bind) = $self->sql_maker->insert($table, \%colvalues);
 
+  $self->_determine_driver;
+
   $self->_query_start( $sql, @bind );
   my $sth = $self->sth($sql);
 
@@ -1237,6 +1277,7 @@
 sub update {
   my $self = shift @_;
   my $source = shift @_;
+  $self->_determine_driver;
   my $bind_attributes = $self->source_bind_attributes($source);
 
   return $self->_execute('update' => [], $source, $bind_attributes, @_);
@@ -1246,7 +1287,7 @@
 sub delete {
   my $self = shift @_;
   my $source = shift @_;
-
+  $self->_determine_driver;
   my $bind_attrs = $self->source_bind_attributes($source);
 
   return $self->_execute('delete' => [], $source, $bind_attrs, @_);
@@ -1888,7 +1929,7 @@
 
 =cut
 
-sub sqlt_type { shift->dbh->{Driver}->{Name} }
+sub sqlt_type { shift->_get_dbh->{Driver}->{Name} }
 
 =head2 bind_attribute_by_data_type
 
@@ -2135,7 +2176,7 @@
 sub deployment_statements {
   my ($self, $schema, $type, $version, $dir, $sqltargs) = @_;
   # Need to be connected to get the correct sqlt_type
-  $self->ensure_connected() unless $type;
+  $self->_get_dbh() unless $type;
   $type ||= $self->sqlt_type;
   $version ||= $schema->schema_version || '1.x';
   $dir ||= './';
@@ -2180,7 +2221,7 @@
     return if $line =~ /^\s+$/; # skip whitespace only
     $self->_query_start($line);
     eval {
-      $self->dbh->do($line); # shouldn't be using ->dbh ?
+      $self->_get_dbh->do($line);
     };
     if ($@) {
       carp qq{$@ (running "${line}")};
@@ -2209,7 +2250,7 @@
 sub datetime_parser {
   my $self = shift;
   return $self->{datetime_parser} ||= do {
-    $self->ensure_connected;
+    $self->_get_dbh;
     $self->build_datetime_parser(@_);
   };
 }

Modified: DBIx-Class/0.08/branches/reduce_pings/t/746mssql.t
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/t/746mssql.t	2009-07-14 12:07:11 UTC (rev 7046)
+++ DBIx-Class/0.08/branches/reduce_pings/t/746mssql.t	2009-07-14 13:09:47 UTC (rev 7047)
@@ -12,7 +12,7 @@
 plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
-plan tests => 27;
+plan tests => 28;
 
 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
 
@@ -48,13 +48,23 @@
 
 my %seen_id;
 
-# fresh $schema so we start unconnected
-$schema = DBICTest::Schema->connect($dsn, $user, $pass);
+my @opts = (
+  { on_connect_call => 'use_dynamic_cursors' },
+  {},
+);
+my $new;
 
-# test primary key handling
-my $new = $schema->resultset('Artist')->create({ name => 'foo' });
-ok($new->artistid > 0, "Auto-PK worked");
+# test Auto-PK with different options
+for my $opts (@opts) {
+  $schema = DBICTest::Schema->clone;
+  $schema->connection($dsn, $user, $pass, $opts);
 
+  $schema->resultset('Artist')->search({ name => 'foo' })->delete;
+
+  $new = $schema->resultset('Artist')->create({ name => 'foo' });
+  ok($new->artistid > 0, "Auto-PK worked");
+}
+
 $seen_id{$new->artistid}++;
 
 # test LIMIT support




More information about the Bast-commits mailing list