X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F73oracle_blob.t;h=6e5c90337ff35dcfb7c82acfd8380f83db184c9f;hb=e2741c7fd695dca054614f297b01d351a45bbf38;hp=fb330c69023c524081f8eb2bb241338c0c5861f5;hpb=cb551b079b096630988312e22becd87fb54fb7de;p=dbsrgits%2FDBIx-Class.git diff --git a/t/73oracle_blob.t b/t/73oracle_blob.t index fb330c6..6e5c903 100644 --- a/t/73oracle_blob.t +++ b/t/73oracle_blob.t @@ -1,3 +1,4 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_oracle'; use strict; @@ -5,10 +6,21 @@ use warnings; use Test::Exception; use Test::More; -use Sub::Name; -use Try::Tiny; -use lib qw(t/lib); +use DBICTest::Schema::BindType; +BEGIN { + DBICTest::Schema::BindType->add_columns( + 'blb2' => { + data_type => 'blob', + is_nullable => 1, + }, + 'clb2' => { + data_type => 'clob', + is_nullable => 1, + } + ); +} + use DBICTest; $ENV{NLS_SORT} = "BINARY"; @@ -81,7 +93,7 @@ SKIP: { 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", blb2 => "blb2:$str", clb2 => "clb2:$str" } ) } "inserted $size without dying"; my %kids = %{$schema->storage->_dbh->{CachedKids}}; @@ -92,8 +104,14 @@ SKIP: { 'multi-part LOB equality query was not cached', ) if $size eq 'large'; 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'); + + for my $type (qw( blob clob clb2 blb2 )) { + is ( + eval { $objs[0]->$type }, + "$type:$str", + "$type inserted/retrieved correctly" + ); + } { local $TODO = '-like comparison on blobs not tested before ora 10 (fails on 8i)' @@ -109,7 +127,7 @@ SKIP: { { blob => "blob:$str", clob => "clob:$str" }, { from => \ "(SELECT * FROM ${q}bindtype_test${q} WHERE ${q}id${q} != ?) ${q}me${q}", - bind => [ [ undef => 12345678 ] ], + bind => [ [ {} => 12345678 ] ], } )->get_column('id')->as_query); @@ -118,13 +136,19 @@ SKIP: { 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', clb2 => 'updated clb2', blb2 => 'updated blb2' }); } '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'); + + for my $type (qw( blob clob clb2 blb2 )) { + is ( + eval { $objs[0]->$type }, + "updated $type", + "$type updated/retrieved correctly" + ); + } lives_ok { $rs->search({ id => $id }) @@ -133,8 +157,14 @@ SKIP: { @objs = $rs->search({ blob => 're-updated blob', clob => 're-updated clob' })->all; is @objs, 1, 'found updated row'; - ok (try { $objs[0]->blob }||'' eq 're-updated blob', 'blob updated/retrieved correctly'); - ok (try { $objs[0]->clob }||'' eq 're-updated clob', 'clob updated/retrieved correctly'); + + for my $type (qw( blob clob )) { + is ( + eval { $objs[0]->$type }, + "re-updated $type", + "$type updated/retrieved correctly" + ); + } lives_ok { $rs->search({ blob => "re-updated blob", clob => "re-updated clob" }) @@ -155,7 +185,7 @@ sub do_creates { do_clean($dbh); - $dbh->do("CREATE TABLE ${q}bindtype_test${q} (${q}id${q} integer NOT NULL PRIMARY KEY, ${q}bytea${q} integer NULL, ${q}blob${q} blob NULL, ${q}blob2${q} blob NULL, ${q}clob${q} clob NULL, ${q}clob2${q} clob NULL, ${q}a_memo${q} integer NULL)"); + $dbh->do("CREATE TABLE ${q}bindtype_test${q} (${q}id${q} integer NOT NULL PRIMARY KEY, ${q}bytea${q} integer NULL, ${q}blob${q} blob NULL, ${q}blb2${q} blob NULL, ${q}clob${q} clob NULL, ${q}clb2${q} clob NULL, ${q}a_memo${q} integer NULL)"); } # clean up our mess