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 my $big_long_string = "\x00\x01\x02 abcd" x 125000;
38 # test inserting a row
40 $new = $schema->resultset('BindType')->create({ bytea => $big_long_string });
42 ok($new->id, "Created a bytea row");
43 is($new->bytea, $big_long_string, "Set the blob correctly.");
46 # test retrieval of the bytea column
48 my $row = $schema->resultset('BindType')->find({ id => $new->id });
49 is($row->get_column('bytea'), $big_long_string, "Created the blob correctly.");
54 'Passing bind attributes to $sth->bind_param() should be implemented (it only works in $storage->insert ATM)';
56 my $rs = $schema->resultset('BindType')->search({ bytea => $big_long_string });
58 # search on the bytea column (select)
61 is($row ? $row->id : undef, $new->id, "Found the row searching on the bytea column.");
64 # search on the bytea column (update)
66 my $new_big_long_string = $big_long_string . "2";
68 $rs->update({ bytea => $new_big_long_string });
69 my $row = $schema->resultset('BindType')->find({ id => $new->id });
70 is($row ? $row->get_column('bytea') : undef, $new_big_long_string,
71 "Updated the row correctly (searching on the bytea column)."
73 $schema->txn_rollback;
77 # search on the bytea column (delete)
81 my $row = $schema->resultset('BindType')->find({ id => $new->id });
82 is($row, undef, "Deleted the row correctly (searching on the bytea column).");
83 $schema->txn_rollback;
88 $dbh->do("DROP TABLE bindtype_test");