X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F746sybase.t;h=b8a42e24811a2a9db0f260c6f1ed7e928893406d;hb=322b7a6b;hp=260fd075cc1715bd90727a579ca80a905045ed14;hpb=166c656193b56e08b472c675e92b9076aac03a53;p=dbsrgits%2FDBIx-Class.git diff --git a/t/746sybase.t b/t/746sybase.t index 260fd07..b8a42e2 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -11,7 +11,7 @@ use DBIx::Class::Storage::DBI::Sybase::NoBindVars; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/}; -my $TESTS = 38 + 2; +my $TESTS = 40 + 2; if (not ($dsn && $user)) { plan skip_all => @@ -19,7 +19,7 @@ if (not ($dsn && $user)) { "\nWarning: This test drops and creates the tables " . "'artist' and 'bindtype_test'"; } else { - plan tests => $TESTS*2; + plan tests => $TESTS*2 + 1; } my @storage_types = ( @@ -188,12 +188,21 @@ SQL } } +# test correlated subquery + my $subq = $schema->resultset('Artist')->search({ artistid => { '>' => 3 } }) + ->get_column('artistid') + ->as_query; + my $subq_rs = $schema->resultset('Artist')->search({ + artistid => { -in => $subq } + }); + is $subq_rs->count, 11, 'correlated subquery'; + # mostly stolen from the blob stuff Nniuq wrote for t/73oracle.t SKIP: { skip 'TEXT/IMAGE support does not work with FreeTDS', 12 if $schema->storage->using_freetds; - my $dbh = $schema->storage->dbh; + my $dbh = $schema->storage->_dbh; { local $SIG{__WARN__} = sub {}; eval { $dbh->do('DROP TABLE bindtype_test') }; @@ -298,11 +307,10 @@ CREATE TABLE money_test ( SQL }); -# First, we'll open a cursor to test insert transactions when there's an active -# cursor. +# test insert transaction when there's an active cursor SKIP: { - skip 'not testing insert with active cursor unless using insert_txn', 1 - unless $schema->storage->insert_txn; + 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; @@ -310,6 +318,26 @@ SQL my $row = $schema->resultset('Money')->create({ amount => 100 }); $row->delete; } 'inserted a row with an active cursor'; + $ping_count-- if $@; # dbh_do calls ->connected + } + +# test insert in an outer transaction when there's an active cursor + TODO: { + local $TODO = 'this should work once we have eager cursors'; + +# clear state, or we get a deadlock on $row->delete +# XXX figure out why this happens + $schema->storage->disconnect; + + lives_ok { + $schema->txn_do(sub { + my $artist_rs = $schema->resultset('Artist'); + $artist_rs->first; + my $row = $schema->resultset('Money')->create({ amount => 100 }); + $row->delete; + }); + } 'inserted a row with an active cursor in outer txn'; + $ping_count-- if $@; # dbh_do calls ->connected } # Now test money values. @@ -341,11 +369,12 @@ SQL diag $@ if $@; } +is $ping_count, 0, 'no pings'; + # clean up our mess END { if (my $dbh = eval { $schema->storage->_dbh }) { eval { $dbh->do("DROP TABLE $_") } for qw/artist bindtype_test money_test/; } - diag "ping count was $ping_count" unless $ping_count == 0; }