change the (incorrect) version check to a check for FreeTDS
[dbsrgits/DBIx-Class.git] / t / 746sybase.t
index 2d0132a..91bfb24 100644 (file)
@@ -9,7 +9,7 @@ use DBICTest;
 
 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/};
 
-my $TESTS = 31 + 2;
+my $TESTS = 29 + 2;
 
 if (not ($dsn && $user)) {
   plan skip_all =>
@@ -46,7 +46,7 @@ for my $storage_type (@storage_types) {
 
   if ($storage_idx == 0 &&
       $schema->storage->isa('DBIx::Class::Storage::DBI::Sybase::NoBindVars')) {
-# no placeholders in this version of Sybase or DBD::Sybase
+# no placeholders in this version of Sybase or DBD::Sybase (or using FreeTDS)
       my $tb = Test::More->builder;
       $tb->skip('no placeholders') for 1..$TESTS;
       next;
@@ -130,8 +130,8 @@ SQL
 
 # mostly stolen from the blob stuff Nniuq wrote for t/73oracle.t
   SKIP: {
-    skip 'Need at least version 1.09 of DBD::Sybase to test TEXT/IMAGE', 14
-        unless $DBD::Sybase::VERSION >= 1.09;
+    skip 'TEXT/IMAGE support does not work with FreeTDS', 12
+      if $schema->storage->_using_freetds;
 
     my $dbh = $schema->storage->dbh;
     {
@@ -155,7 +155,7 @@ SQL
     my $maxloblen = length $binstr{'large'};
     note
       "Localizing LongReadLen to $maxloblen to avoid truncation of test data";
-    local $dbh->{'LongReadLen'} = $maxloblen;
+    local $dbh->{'LongReadLen'} = $maxloblen * 2;
 
     my $rs = $schema->resultset('BindType');
     my $last_id;
@@ -171,27 +171,13 @@ SQL
         $last_id = $created->id if $created;
 
         my $got = eval {
-          $rs->search({ id => $last_id }, { select => [$type] })->single->$type
+          $rs->find($last_id)->$type
         };
         diag $@ if $@;
         ok($got eq $binstr{$size}, "verified inserted $size $type");
       }
     }
 
-    # try a blob update
-    TODO: {
-      local $TODO = 'updating TEXT/IMAGE does not work yet';
-
-      my $new_str = $binstr{large} . 'foo';
-      eval { $rs->search({ id => $last_id })->update({ blob => $new_str }) };
-      ok !$@, 'updated blob successfully';
-      diag $@ if $@;
-      ok(eval {
-        $rs->search({ id => $last_id }, { select => ['blob'] })->single->blob
-      } eq $new_str, "verified updated blob" );
-      diag $@ if $@;
-    }
-
     # blob insert with explicit PK
     {
       local $SIG{__WARN__} = sub {};
@@ -208,39 +194,25 @@ SQL
       ],{ RaiseError => 1, PrintError => 0 });
     }
     my $created = eval { $rs->create( { id => 1, blob => $binstr{large} } ) };
-    ok(!$@, "inserted large blob without dying");
+    ok(!$@, "inserted large blob without dying with manual PK");
     diag $@ if $@;
 
     my $got = eval {
-      $rs->search({ id => 1 }, { select => ['blob'] })->single->blob
+      $rs->find(1)->blob
     };
     diag $@ if $@;
-    ok($got eq $binstr{large}, "verified inserted large blob");
-
-    # Test select args ordering on a ->find for a table with one blob
-    {
-      local $SIG{__WARN__} = sub {};
-      eval { $dbh->do('DROP TABLE single_blob_test') };
+    ok($got eq $binstr{large}, "verified inserted large blob with manual PK");
 
-      $dbh->do(qq[
-        CREATE TABLE single_blob_test 
-        (
-          id    INT   IDENTITY PRIMARY KEY,
-          blob  IMAGE NULL,
-          foo VARCHAR(256) NULL
-        )
-      ],{ RaiseError => 1, PrintError => 0 });
-    }
-    $rs = $schema->resultset('SingleBlob');
-    $created = eval { $rs->create({
-      blob => $binstr{large}, foo => 'dummy'
-    }) };
-    ok(!$@, "inserted single large blob without dying");
+    # try a blob update
+    my $new_str = $binstr{large} . 'mtfnpy';
+    eval { $rs->search({ id => 1 })->update({ blob => $new_str }) };
+    ok !$@, 'updated blob successfully';
     diag $@ if $@;
-
-    $got = eval { $rs->find($created->id)->blob };
+    $got = eval {
+      $rs->find(1)->blob
+    };
     diag $@ if $@;
-    ok($got eq $binstr{large}, "verified inserted large blob through ->find");
+    ok($got eq $new_str, "verified updated blob");
   }
 }
 
@@ -249,6 +221,5 @@ END {
   if (my $dbh = eval { $schema->storage->_dbh }) {
     $dbh->do('DROP TABLE artist');
     eval { $dbh->do('DROP TABLE bindtype_test')    };
-    eval { $dbh->do('DROP TABLE single_blob_test') };
   }
 }