X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F72pg_bytea.t;h=7049b319cf8e3c8895f22df497e7e6ce285ba1c1;hb=74919a00766bc8f9bd9f6170d1977e186ce676d5;hp=0468976711d67d93b7b3ec34020324aa2d02207d;hpb=199fbc453ec03891d0e156d7353c5e992ba4de47;p=dbsrgits%2FDBIx-Class.git diff --git a/t/72pg_bytea.t b/t/72pg_bytea.t index 0468976..7049b31 100644 --- a/t/72pg_bytea.t +++ b/t/72pg_bytea.t @@ -1,20 +1,23 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw(test_rdbms_pg binary_data); + use strict; use warnings; use Test::More; -use DBIx::Class::Optional::Dependencies (); +use DBIx::Class::_Util 'modver_gt_or_eq'; + use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); - my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; -plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' - unless ($dsn && $dbuser); +my $schema = DBICTest::Schema->connect($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); -my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); +plan skip_all => 'DBD::Pg < 2.17.2 does not work with Pg >= 9.0 BYTEA columns' if ( + ! modver_gt_or_eq('DBD::Pg', '2.17.2') + and + $schema->storage->_server_info->{normalized_dbms_version} >= 9.0 +); my $dbh = $schema->storage->dbh; @@ -93,7 +96,32 @@ my $new; ok($new->bytea eq $big_long_string, 'bytea value made it to db'); } +# test inserting a row via populate() (bindtype propagation through execute_for_fetch) +# use a new $dbh to ensure no leakage due to prepare_cached +{ + my $cnt = 4; + + $schema->storage->_dbh(undef); + my $rs = $schema->resultset('BindType'); + $rs->delete; + + $rs->populate([ + [qw/id bytea/], + map { [ + \[ '?', [ {} => $_ ] ], + "pop_${_}_" . $big_long_string, + ]} (1 .. $cnt) + ]); + + is($rs->count, $cnt, 'All rows were correctly inserted'); + for (1..$cnt) { + my $r = $rs->find({ bytea => "pop_${_}_" . $big_long_string }); + is ($r->id, $_, "Row $_ found after find() on the blob"); + + } +} + done_testing; -eval { $dbh->do("DROP TABLE bindtype_test") }; +eval { $schema->storage->dbh_do(sub { $_[1]->do("DROP TABLE bindtype_test") } ) };