X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F746mssql.t;h=620258e8d592099ebafd7ffcaaa262bc39b41fa0;hb=8bc474676193d8832932f01cc60f85e7c1d44c76;hp=f559945fd2097022ce7298b1354a0088ac6adadc;hpb=fcb7fcbb6bde5f9a211c62011b3110f07828caec;p=dbsrgits%2FDBIx-Class.git diff --git a/t/746mssql.t b/t/746mssql.t index f559945..620258e 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -3,12 +3,16 @@ use warnings; use Test::More; use Test::Exception; +use Try::Tiny; +use DBIx::Class::SQLMaker::LimitDialects; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use DBIC::SqlMakerTest; -use Try::Tiny; -use DBIx::Class::SQLMaker::LimitDialects; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mssql_odbc') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mssql_odbc'); + my $OFFSET = DBIx::Class::SQLMaker::LimitDialects->__offset_bindtype; my $TOTAL = DBIx::Class::SQLMaker::LimitDialects->__total_bindtype; @@ -51,25 +55,32 @@ lives_ok { my %opts = ( use_mars => - { on_connect_call => 'use_mars' }, + { opts => { on_connect_call => 'use_mars' } }, use_dynamic_cursors => - { on_connect_call => 'use_dynamic_cursors' }, + { opts => { on_connect_call => 'use_dynamic_cursors' }, required => 1 }, use_server_cursors => - { on_connect_call => 'use_server_cursors' }, - plain => - {}, + { opts => { on_connect_call => 'use_server_cursors' } }, + NO_OPTION => + { opts => {}, required => 1 }, ); for my $opts_name (keys %opts) { SKIP: { - my $opts = $opts{$opts_name}; + my $opts = $opts{$opts_name}{opts}; $schema = DBICTest::Schema->connect($dsn, $user, $pass, $opts); try { $schema->storage->ensure_connected } catch { - skip "$opts_name not functional in this configuration: $_", 1; + if ($opts{$opts_name}{required}) { + BAIL_OUT "on_connect_call option '$opts_name' is not functional: $_"; + } + else { + skip +"on_connect_call option '$opts_name' not functional in this configuration: $_", +1; + } }; $schema->storage->dbh_do (sub { @@ -522,27 +533,41 @@ CREATE TABLE money_test ( SQL }); - my $rs = $schema->resultset('Money'); - my $row; + TODO: { + my $freetds_and_dynamic_cursors = 1 + if $opts_name eq 'use_dynamic_cursors' && + $schema->storage->using_freetds; - lives_ok { - $row = $rs->create({ amount => 100 }); - } 'inserted a money value'; + local $TODO = +'these tests fail on freetds with dynamic cursors for some reason' + if $freetds_and_dynamic_cursors; + local $ENV{DBIC_NULLABLE_KEY_NOWARN} = 1 + if $freetds_and_dynamic_cursors; - cmp_ok $rs->find($row->id)->amount, '==', 100, 'money value round-trip'; + my $rs = $schema->resultset('Money'); + my $row; - lives_ok { - $row->update({ amount => 200 }); - } 'updated a money value'; + lives_ok { + $row = $rs->create({ amount => 100 }); + } 'inserted a money value'; - cmp_ok $rs->find($row->id)->amount, '==', 200, - 'updated money value round-trip'; + cmp_ok ((try { $rs->find($row->id)->amount })||0, '==', 100, + 'money value round-trip'); - lives_ok { - $row->update({ amount => undef }); - } 'updated a money value to NULL'; + lives_ok { + $row->update({ amount => 200 }); + } 'updated a money value'; - is $rs->find($row->id)->amount, undef,'updated money value to NULL round-trip'; + cmp_ok ((try { $rs->find($row->id)->amount })||0, '==', 200, + 'updated money value round-trip'); + + lives_ok { + $row->update({ amount => undef }); + } 'updated a money value to NULL'; + + is try { $rs->find($row->id)->amount }, undef, + 'updated money value to NULL round-trip'; + } } } }