8 my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
10 plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
11 unless ($dsn && $dbuser);
15 my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
17 my $dbh = $schema->storage->dbh;
20 local $SIG{__WARN__} = sub {};
21 $dbh->do('DROP TABLE IF EXISTS bindtype_test');
23 # the blob/clob are for reference only, will be useful when we switch to SQLT and can test Oracle along the way
25 CREATE TABLE bindtype_test
27 id serial NOT NULL PRIMARY KEY,
32 ],{ RaiseError => 1, PrintError => 1 });
35 $schema->storage->debug(0); # these tests spew up way too much stuff, disable trace
37 my $big_long_string = "\x00\x01\x02 abcd" x 125000;
40 # test inserting a row
42 $new = $schema->resultset('BindType')->create({ bytea => $big_long_string });
44 ok($new->id, "Created a bytea row");
45 is($new->bytea, $big_long_string, "Set the blob correctly.");
48 # test retrieval of the bytea column
50 my $row = $schema->resultset('BindType')->find({ id => $new->id });
51 is($row->get_column('bytea'), $big_long_string, "Created the blob correctly.");
55 my $rs = $schema->resultset('BindType')->search({ bytea => $big_long_string });
57 # search on the bytea column (select)
60 is($row ? $row->id : undef, $new->id, "Found the row searching on the bytea column.");
63 # search on the bytea column (update)
65 my $new_big_long_string = $big_long_string . "2";
67 $rs->update({ bytea => $new_big_long_string });
68 my $row = $schema->resultset('BindType')->find({ id => $new->id });
69 is($row ? $row->get_column('bytea') : undef, $new_big_long_string,
70 "Updated the row correctly (searching on the bytea column)."
72 $schema->txn_rollback;
76 # search on the bytea column (delete)
80 my $row = $schema->resultset('BindType')->find({ id => $new->id });
81 is($row, undef, "Deleted the row correctly (searching on the bytea column).");
82 $schema->txn_rollback;
87 $dbh->do("DROP TABLE bindtype_test");