From: Rafael Kitover Date: Fri, 24 Dec 2010 12:53:11 +0000 (+0100) Subject: Extend tests for MARs under MSSQL over DBD::Sybase X-Git-Tag: v0.08191~35 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b30f1a32a87751dccc860e8538aadbca0300f868;p=dbsrgits%2FDBIx-Class.git Extend tests for MARs under MSSQL over DBD::Sybase --- diff --git a/t/74mssql.t b/t/74mssql.t index 5df9b5e..223709d 100644 --- a/t/74mssql.t +++ b/t/74mssql.t @@ -23,6 +23,8 @@ plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test ok ($srv_ver, 'Got a test server version on fresh schema: ' . ($srv_ver||'???') ); } +my $schema; + my $testdb_supports_placeholders = DBICTest::Schema->connect($dsn, $user, $pass) ->storage ->_supports_typeless_placeholders; @@ -31,7 +33,6 @@ my @test_storages = ( 'DBI::Sybase::Microsoft_SQL_Server::NoBindVars', ); -my $schema; for my $storage_type (@test_storages) { $schema = DBICTest::Schema->connect($dsn, $user, $pass); @@ -42,6 +43,12 @@ for my $storage_type (@test_storages) { } $schema->storage->ensure_connected; + + if ($storage_type =~ /NoBindVars\z/) { + is $schema->storage->disable_sth_caching, 1, + 'prepare_cached disabled for NoBindVars'; + } + isa_ok($schema->storage, "DBIx::Class::Storage::$storage_type"); SKIP: { @@ -107,10 +114,9 @@ for my $storage_type (@test_storages) { amount MONEY NULL ) SQL + }); - }); - - my $rs = $schema->resultset('Money'); + my $rs = $schema->resultset('Money'); my $row; lives_ok { @@ -133,41 +139,59 @@ SQL is $rs->find($row->id)->amount, undef, 'updated money value to NULL round-trip'; - $rs->create({ amount => 300 }) for (1..3); - - # test multiple active statements - lives_ok { - my $artist_rs = $schema->resultset('Artist'); - while (my $row = $rs->next) { - my $artist = $artist_rs->next; - } - $rs->reset; - } 'multiple active statements'; - $rs->delete; # test simple transaction with commit lives_ok { $schema->txn_do(sub { - $rs->create({ amount => 400 }); + $rs->create({ amount => 300 }); }); } 'simple transaction'; - cmp_ok $rs->first->amount, '==', 400, 'committed'; - $rs->reset; + cmp_ok $rs->first->amount, '==', 300, 'committed'; + $rs->reset; $rs->delete; # test rollback throws_ok { $schema->txn_do(sub { - $rs->create({ amount => 400 }); + $rs->create({ amount => 700 }); die 'mtfnpy'; }); } qr/mtfnpy/, 'simple failed txn'; is $rs->first, undef, 'rolled back'; + $rs->reset; + $rs->delete; + + # test multiple active statements + { + $rs->create({ amount => 800 + $_ }) for 1..3; + + my @map = ( + [ 'Artist 1', '801.00' ], + [ 'Artist 2', '802.00' ], + [ 'Artist 3', '803.00' ] + ); + + my $artist_rs = $schema->resultset('Artist')->search({ + name => { -like => 'Artist %' } + });; + + my $i = 0; + + while (my $money_row = $rs->next) { + my $artist_row = $artist_rs->next; + + is_deeply [ $artist_row->name, $money_row->amount ], $map[$i++], + 'multiple active statements'; + } + $rs->reset; + $rs->delete; + } + # test RNO detection when version detection fails SKIP: { diff --git a/t/lib/DBICTest/Schema/Event.pm b/t/lib/DBICTest/Schema/Event.pm index d5bd0be..30472d1 100644 --- a/t/lib/DBICTest/Schema/Event.pm +++ b/t/lib/DBICTest/Schema/Event.pm @@ -11,7 +11,7 @@ __PACKAGE__->table('event'); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 }, -# this MUST be 'date' for the Firebird tests +# this MUST be 'date' for the Firebird and SQLAnywhere tests starts_at => { data_type => 'date' }, created_on => { data_type => 'timestamp' },