Bring back _RowNumberOver deleted in the sqla commotion (revs: 5096,5322,5383)
[dbsrgits/DBIx-Class-Historic.git] / t / bindtype_columns.t
index d88815d..05b514c 100644 (file)
@@ -5,23 +5,46 @@ use Test::More;
 use lib qw(t/lib);
 use DBICTest;
 
-my $schema = DBICTest->init_schema();
+my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
 
-plan tests => 2;
+plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
+  unless ($dsn && $dbuser);
+  
+plan tests => 3;
+
+my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
+
+my $dbh = $schema->storage->dbh;
 
-#Bindtest
 {
-       my $new = $schema->resultset("Artist")->new({
-       
-               artistid=>25,
-               name=>'JohnNapiorkowski',
-       });
-       
-       $new->update_or_insert;
-       
-       my $resultset = $schema->resultset("Artist")->find({artistid=>25});
-       
-       is($resultset->id, 25, 'Testing New ID');
-       is($resultset->name, 'JohnNapiorkowski', 'Testing New Name');
+    local $SIG{__WARN__} = sub {};
+    $dbh->do('DROP TABLE IF EXISTS artist');
+
+    # the blob/clob are for reference only, will be useful when we switch to SQLT and can test Oracle along the way
+    $dbh->do(qq[
+        CREATE TABLE bindtype_test 
+        (
+            id              serial       NOT NULL   PRIMARY KEY,
+            bytea           bytea        NULL,
+            blob            bytea        NULL,
+            clob            text         NULL
+        );
+    ],{ RaiseError => 1, PrintError => 1 });
 }
 
+# test primary key handling
+my $big_long_string    = 'abcd' x 250000;
+
+my $new = $schema->resultset('BindType')->create({ bytea => $big_long_string });
+
+ok($new->id, "Created a bytea row");
+is($new->bytea,        $big_long_string, "Set the blob correctly.");
+
+my $rs = $schema->resultset('BindType')->find({ id => $new->id });
+
+is($rs->get_column('bytea'), $big_long_string, "Created the blob correctly.");
+
+$dbh->do("DROP TABLE bindtype_test");
+
+
+