use DBIx::Class::Optional::Dependencies ();
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;
-use DBIC::SqlMakerTest;
my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/};
sub _run_blob_tests {
SKIP: {
-TODO: {
my ($schema, $opt) = @_;
my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
$binstr{'large'} = $binstr{'small'} x 1024;
. ': 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", blb2 => "blb2:$str", clb2 => "clb2:$str" } )
} "inserted $size without dying";
my %kids = %{$schema->storage->_dbh->{CachedKids}};
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]->clb2 }||'' eq "clb2:$str", "clb2 inserted correctly");
+ ok (try { $objs[0]->blb2 }||'' eq "blb2:$str", "blb2 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;
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');
+ ok (try { $objs[0]->clb2 }||'' eq "updated clb2", "clb2 updated correctly");
+ ok (try { $objs[0]->blb2 }||'' eq "updated blb2", "blb2 updated correctly");
lives_ok {
$rs->search({ id => $id })
@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);
}
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
}
END {
- for ($dbh) {
- next unless $_;
+ if ($dbh) {
local $SIG{__WARN__} = sub {};
- do_clean($_);
- $_->disconnect;
+ do_clean($dbh);
+ undef $dbh;
}
}