Centralize remaining uses of Sub::Name within _Util
[dbsrgits/DBIx-Class.git] / t / 73oracle_blob.t
index 55b1daf..d067c2b 100644 (file)
@@ -1,27 +1,35 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_oracle';
+
 use strict;
 use warnings;
 
 use Test::Exception;
 use Test::More;
-use Sub::Name;
 use Try::Tiny;
-use DBIx::Class::Optional::Dependencies ();
-
-use lib qw(t/lib);
-use DBICTest;
-
-my ($dsn,  $user,  $pass)  = @ENV{map { "DBICTEST_ORA_${_}" }  qw/DSN USER PASS/};
 
-plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test.'
-  unless ($dsn && $user && $pass);
+use DBICTest::Schema::BindType;
+BEGIN {
+  DBICTest::Schema::BindType->add_columns(
+    'blb2' => {
+      data_type => 'blob',
+      is_nullable => 1,
+    },
+    'clb2' => {
+      data_type => 'clob',
+      is_nullable => 1,
+    }
+  );
+}
 
-plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_oracle')
-  unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_oracle');
+use DBICTest;
 
 $ENV{NLS_SORT} = "BINARY";
 $ENV{NLS_COMP} = "BINARY";
 $ENV{NLS_LANG} = "AMERICAN";
 
+my ($dsn,  $user,  $pass)  = @ENV{map { "DBICTEST_ORA_${_}" }  qw/DSN USER PASS/};
+
 my $v = do {
   my $si = DBICTest::Schema->connect($dsn, $user, $pass)->storage->_server_info;
   $si->{normalized_dbms_version}
@@ -59,7 +67,7 @@ SKIP: {
   my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
   $binstr{'large'} = $binstr{'small'} x 1024;
 
-  my $maxloblen = (length $binstr{'large'}) + 6;
+  my $maxloblen = (length $binstr{'large'}) + 5;
   note "Localizing LongReadLen to $maxloblen to avoid truncation of test data";
   local $dbh->{'LongReadLen'} = $maxloblen;
 
@@ -86,7 +94,7 @@ SKIP: {
 
     my $str = $binstr{$size};
     lives_ok {
-      $rs->create( { 'id' => $id, blob => "blob:$str", clob => "clob:$str", blob2 => "blob2:$str", clob2 => "clob2:$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}};
@@ -99,8 +107,8 @@ SKIP: {
     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");
+    ok (try { $objs[0]->clb2 }||'' eq "clb2:$str", "clb2 inserted correctly");
+    ok (try { $objs[0]->blb2 }||'' eq "blb2:$str", "blb2 inserted correctly");
 
     {
       local $TODO = '-like comparison on blobs not tested before ora 10 (fails on 8i)'
@@ -116,7 +124,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);
 
@@ -125,15 +133,15 @@ SKIP: {
 
     lives_ok {
       $rs->search({ id => $id, blob => "blob:$str", clob => "clob:$str" })
-        ->update({ blob => 'updated blob', clob => 'updated clob', clob2 => 'updated clob2', blob2 => 'updated blob2' });
+        ->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]->clob2 }||'' eq "updated clob2", "clob2 updated correctly");
-    ok (try { $objs[0]->blob2 }||'' eq "updated blob2", "blob2 updated 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  })
@@ -164,7 +172,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