X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F73oracle_blob.t;h=20a680e98ba5c8f71d812e6f2022290e197a5c04;hb=74b5397c077a964ed301d18f5ccda72afa91f353;hp=46d91f110ada6ba1626e0c0480f6033c6981847a;hpb=1143e5bdc4571a4b6f601940643e611d969e2cfb;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/73oracle_blob.t b/t/73oracle_blob.t index 46d91f1..20a680e 100644 --- a/t/73oracle_blob.t +++ b/t/73oracle_blob.t @@ -9,7 +9,6 @@ use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -use DBIC::SqlMakerTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; @@ -24,12 +23,11 @@ $ENV{NLS_COMP} = "BINARY"; $ENV{NLS_LANG} = "AMERICAN"; my $v = do { - my $v = DBICTest::Schema->connect($dsn, $user, $pass)->storage->_dbh_get_info(18); - $v =~ /^(\d+)\.(\d+)/ - or die "Unparseable Oracle server version: $v\n"; - - sprintf('%d.%03d', $1, $2); + my $si = DBICTest->connect_schema($dsn, $user, $pass)->storage->_server_info; + $si->{normalized_dbms_version} + or die "Unparseable Oracle server version: $si->{dbms_version}\n"; }; + ########## # the recyclebin (new for 10g) sometimes comes in the way my $on_connect_sql = $v >= 10 ? ["ALTER SESSION SET recyclebin = OFF"] : []; @@ -45,7 +43,7 @@ my $dbh; my $schema; for my $opt (@tryopt) { - my $schema = DBICTest::Schema->connect($dsn, $user, $pass, $opt); + my $schema = DBICTest->connect_schema($dsn, $user, $pass, $opt); $dbh = $schema->storage->dbh; my $q = $schema->storage->sql_maker->quote_char || ''; @@ -57,12 +55,11 @@ for my $opt (@tryopt) { sub _run_blob_tests { SKIP: { -TODO: { my ($schema, $opt) = @_; my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) ); $binstr{'large'} = $binstr{'small'} x 1024; - my $maxloblen = (length $binstr{'large'}) + 5; + my $maxloblen = (length $binstr{'large'}) + 6; note "Localizing LongReadLen to $maxloblen to avoid truncation of test data"; local $dbh->{'LongReadLen'} = $maxloblen; @@ -80,21 +77,16 @@ TODO: { . ': https://rt.cpan.org/Ticket/Display.html?id=64206' if $q; - # so we can disable BLOB mega-output - my $orig_debug = $schema->storage->debug; - my $id; foreach my $size (qw( small large )) { $id++; - local $schema->storage->{debug} = $size eq 'large' - ? 0 - : $orig_debug - ; + local $schema->storage->{debug} = 0 + if $size eq 'large'; my $str = $binstr{$size}; lives_ok { - $rs->create( { 'id' => $id, blob => "blob:$str", clob => "clob:$str" } ) + $rs->create( { 'id' => $id, blob => "blob:$str", clob => "clob:$str", blob2 => "blob2:$str", clob2 => "clob2:$str" } ) } "inserted $size without dying"; my %kids = %{$schema->storage->_dbh->{CachedKids}}; @@ -107,8 +99,10 @@ TODO: { is @objs, 1, 'One row found matching on both LOBs'; ok (try { $objs[0]->blob }||'' eq "blob:$str", 'blob inserted/retrieved correctly'); ok (try { $objs[0]->clob }||'' eq "clob:$str", 'clob inserted/retrieved correctly'); + ok (try { $objs[0]->clob2 }||'' eq "clob2:$str", "clob2 inserted correctly"); + ok (try { $objs[0]->blob2 }||'' eq "blob2:$str", "blob2 inserted correctly"); - TODO: { + { local $TODO = '-like comparison on blobs not tested before ora 10 (fails on 8i)' if $schema->storage->_server_info->{normalized_dbms_version} < 10; @@ -131,13 +125,15 @@ TODO: { lives_ok { $rs->search({ id => $id, blob => "blob:$str", clob => "clob:$str" }) - ->update({ blob => 'updated blob', clob => 'updated clob' }); + ->update({ blob => 'updated blob', clob => 'updated clob', clob2 => 'updated clob2', blob2 => 'updated blob2' }); } 'blob UPDATE with blobs in WHERE clause survived'; @objs = $rs->search({ blob => "updated blob", clob => 'updated clob' })->all; is @objs, 1, 'found updated row'; ok (try { $objs[0]->blob }||'' eq "updated blob", 'blob updated/retrieved correctly'); ok (try { $objs[0]->clob }||'' eq "updated clob", 'clob updated/retrieved correctly'); + ok (try { $objs[0]->clob2 }||'' eq "updated clob2", "clob2 updated correctly"); + ok (try { $objs[0]->blob2 }||'' eq "updated blob2", "blob2 updated correctly"); lives_ok { $rs->search({ id => $id }) @@ -156,9 +152,7 @@ TODO: { @objs = $rs->search({ blob => "re-updated blob", clob => 're-updated clob' })->all; is @objs, 0, 'row deleted successfully'; } - - $schema->storage->debug ($orig_debug); -}} +} do_clean ($dbh); } @@ -187,10 +181,9 @@ sub do_clean { } END { - for ($dbh) { - next unless $_; + if ($dbh) { local $SIG{__WARN__} = sub {}; - do_clean($_); - $_->disconnect; + do_clean($dbh); + undef $dbh; } }