X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbindtype_columns.t;h=0a3f77d173e2058748e4e316616481b7a34f8723;hb=d9a898ca39d6af80ee585351e9c6468a95fe2b17;hp=9d0ad92c77f7f6b20d2957aaebb8c29c2c6a6ad9;hpb=eda28767c55e79a4bfca922e36a4b2227155f7e0;p=dbsrgits%2FDBIx-Class.git diff --git a/t/bindtype_columns.t b/t/bindtype_columns.t index 9d0ad92..0a3f77d 100644 --- a/t/bindtype_columns.t +++ b/t/bindtype_columns.t @@ -12,49 +12,39 @@ plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' plan tests => 3; -my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass); +my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); my $dbh = $schema->storage->dbh; -$dbh->do(qq[ - - CREATE TABLE artist - ( - artistid serial NOT NULL PRIMARY KEY, - media bytea NOT NULL, - name varchar 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, - }, -); +{ + local $SIG{__WARN__} = sub {}; + $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 + $dbh->do(qq[ + CREATE TABLE bindtype_test + ( + id serial NOT NULL PRIMARY KEY, + bytea bytea NULL, + blob bytea NULL, + clob text NULL + ); + ],{ RaiseError => 1, PrintError => 1 }); +} # test primary key handling my $big_long_string = 'abcd' x 250000; -my $new = $schema->resultset('Artist')->create({ media => $big_long_string }); +my $new = $schema->resultset('BindType')->create({ bytea => $big_long_string }); -ok($new->artistid, "Created a blob row"); -is($new->media, $big_long_string, "Set the blob correctly."); +ok($new->id, "Created a bytea row"); +is($new->bytea, $big_long_string, "Set the blob correctly."); -my $rs = $schema->resultset('Artist')->find({artistid=>$new->artistid}); +my $rs = $schema->resultset('BindType')->find({ id => $new->id }); -is($rs->get_column('media'), $big_long_string, "Created the blob correctly."); +is($rs->get_column('bytea'), $big_long_string, "Created the blob correctly."); -$dbh->do("DROP TABLE artist"); +$dbh->do("DROP TABLE bindtype_test");