Commit | Line | Data |
6e399b4f |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
9fdf90df |
8 | my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; |
6e399b4f |
9 | |
9fdf90df |
10 | plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' |
11 | unless ($dsn && $dbuser); |
12 | |
13 | plan tests => 3; |
14 | |
77d76d0f |
15 | my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); |
9fdf90df |
16 | |
eda28767 |
17 | my $dbh = $schema->storage->dbh; |
9fdf90df |
18 | |
bb452615 |
19 | { |
20 | local $SIG{__WARN__} = sub {}; |
a65c1894 |
21 | $dbh->do('DROP TABLE IF EXISTS bindtype_test'); |
6ec7d1bb |
22 | |
23 | # the blob/clob are for reference only, will be useful when we switch to SQLT and can test Oracle along the way |
bb452615 |
24 | $dbh->do(qq[ |
6ec7d1bb |
25 | CREATE TABLE bindtype_test |
bb452615 |
26 | ( |
6ec7d1bb |
27 | id serial NOT NULL PRIMARY KEY, |
28 | bytea bytea NULL, |
29 | blob bytea NULL, |
30 | clob text NULL |
bb452615 |
31 | ); |
32 | ],{ RaiseError => 1, PrintError => 1 }); |
33 | } |
9fdf90df |
34 | |
9fdf90df |
35 | # test primary key handling |
36 | my $big_long_string = 'abcd' x 250000; |
37 | |
6ec7d1bb |
38 | my $new = $schema->resultset('BindType')->create({ bytea => $big_long_string }); |
9fdf90df |
39 | |
6ec7d1bb |
40 | ok($new->id, "Created a bytea row"); |
41 | is($new->bytea, $big_long_string, "Set the blob correctly."); |
9fdf90df |
42 | |
6ec7d1bb |
43 | my $rs = $schema->resultset('BindType')->find({ id => $new->id }); |
9fdf90df |
44 | |
6ec7d1bb |
45 | is($rs->get_column('bytea'), $big_long_string, "Created the blob correctly."); |
9fdf90df |
46 | |
6ec7d1bb |
47 | $dbh->do("DROP TABLE bindtype_test"); |
9fdf90df |
48 | |
49 | |
6e399b4f |
50 | |