plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
unless ($dsn && $dbuser);
-plan tests => 3;
+plan tests => 6;
my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
{
local $SIG{__WARN__} = sub {};
- $dbh->do('DROP TABLE IF EXISTS artist');
+ $dbh->do('DROP TABLE IF EXISTS bindtype_test');
+
+ # the blob/clob are for reference only, will be useful when we switch to SQLT and can test Oracle along the way
+
+ # 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 artist
+ CREATE TABLE bindtype_test
(
- artistid serial NOT NULL PRIMARY KEY,
- media bytea NOT NULL,
- name varchar(100) NULL,
- rank integer NOT NULL DEFAULT '13',
- charfield char(10) NULL
+ id serial NOT NULL PRIMARY KEY,
+ bytea bytea NULL,
+ blob bytea NULL,
+ clob text NULL
);
],{ RaiseError => 1, PrintError => 1 });
}
-$schema->class('Artist')->load_components(qw/
-
- PK::Auto
- Core
-/);
-
-$schema->class('Artist')->add_columns(
-
- "media", {
-
- data_type => "bytea",
- is_nullable => 0,
- },
-);
-
-# test primary key handling
-my $big_long_string = 'abcd' x 250000;
-
-my $new = $schema->resultset('Artist')->create({ media => $big_long_string });
-
-ok($new->artistid, "Created a blob row");
-is($new->media, $big_long_string, "Set the blob correctly.");
+# test retrieval of the bytea column
+{
+ my $row = $schema->resultset('BindType')->find({ id => $new->id });
+ is($row->get_column('bytea'), $big_long_string, "Created the blob correctly.");
+}
-my $rs = $schema->resultset('Artist')->find({artistid=>$new->artistid});
+my $new = $schema->resultset('BindType')->create({ bytea => $big_long_string });
-is($rs->get_column('media'), $big_long_string, "Created the blob correctly.");
+ok($new->id, "Created a bytea row");
+is($new->bytea, $big_long_string, "Set the blob correctly.");
-$dbh->do("DROP TABLE artist");
+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");
+$dbh->do("DROP TABLE bindtype_test");