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 | |
19 | $dbh->do(qq[ |
20 | |
21 | CREATE TABLE artist |
22 | ( |
23 | artistid serial NOT NULL PRIMARY KEY, |
24 | media bytea NOT NULL, |
25 | name varchar NULL |
26 | ); |
27 | ],{ RaiseError => 1, PrintError => 1 }); |
28 | |
29 | |
eda28767 |
30 | $schema->class('Artist')->load_components(qw/ |
9fdf90df |
31 | |
32 | PK::Auto |
33 | Core |
34 | /); |
35 | |
eda28767 |
36 | $schema->class('Artist')->add_columns( |
6e399b4f |
37 | |
9fdf90df |
38 | "media", { |
6e399b4f |
39 | |
9fdf90df |
40 | data_type => "bytea", |
7036ea60 |
41 | is_nullable => 0, |
9fdf90df |
42 | }, |
43 | ); |
44 | |
45 | # test primary key handling |
46 | my $big_long_string = 'abcd' x 250000; |
47 | |
eda28767 |
48 | my $new = $schema->resultset('Artist')->create({ media => $big_long_string }); |
9fdf90df |
49 | |
50 | ok($new->artistid, "Created a blob row"); |
51 | is($new->media, $big_long_string, "Set the blob correctly."); |
52 | |
eda28767 |
53 | my $rs = $schema->resultset('Artist')->find({artistid=>$new->artistid}); |
9fdf90df |
54 | |
55 | is($rs->get_column('media'), $big_long_string, "Created the blob correctly."); |
56 | |
57 | $dbh->do("DROP TABLE artist"); |
58 | |
59 | |
6e399b4f |
60 | |