X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F72pg.t;h=e5d1bef432dd4c82e60884ac3e35da86661fba0a;hb=8d52ddcdbc0ec1b7e4ab79c5ea2212575637052f;hp=f3ad48e37db8a1d742f1258cc342995b0537ca91;hpb=bab40deebe87977cb35055321a722d0d1ccebcd5;p=dbsrgits%2FDBIx-Class.git diff --git a/t/72pg.t b/t/72pg.t index f3ad48e..e5d1bef 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -23,12 +23,20 @@ EOM our @test_classes; #< array that will be pushed into by test classes defined in this file DBICTest::Schema->load_classes( map {s/.+:://;$_} @test_classes ) if @test_classes; +my $test_server_supports_insert_returning = do { + my $s = DBICTest::Schema->connect($dsn, $user, $pass); + $s->storage->_determine_driver; + $s->storage->_supports_insert_returning; +}; + my $schema; -for my $use_insert_returning (0..1) { +for my $use_insert_returning ($test_server_supports_insert_returning + ? (0,1) + : (0) +) { no warnings qw/redefine once/; - require DBIx::Class::Storage::DBI::Pg; - local *DBIx::Class::Storage::DBI::Pg::can_insert_returning = sub { + local *DBIx::Class::Storage::DBI::Pg::_supports_insert_returning = sub { $use_insert_returning }; @@ -63,6 +71,7 @@ for my $use_insert_returning (0..1) { ### connect, create postgres-specific test schema $schema = DBICTest::Schema->connect($dsn, $user, $pass); + $schema->storage->ensure_connected; drop_test_schema($schema); create_test_schema($schema); @@ -229,12 +238,15 @@ for my $use_insert_returning (0..1) { $schema2->source("Artist")->name("dbic_t_schema.artist"); $schema->txn_do( sub { - my $artist = $schema->resultset('Artist')->search( + my $rs = $schema->resultset('Artist')->search( { artistid => 1 }, $t->{update_lock} ? { for => 'update' } : {} - )->first; + ); + ok ($rs->count, 'Count works'); + + my $artist = $rs->next; is($artist->artistid, 1, "select returns artistid = 1"); $timed_out = 0; @@ -269,7 +281,7 @@ for my $use_insert_returning (0..1) { ######## test non-serial auto-pk - if ($schema->storage->can_insert_returning) { + if ($schema->storage->_supports_insert_returning) { $schema->source('TimestampPrimaryKey')->name('dbic_t_schema.timestamp_primary_key_test'); my $row = $schema->resultset('TimestampPrimaryKey')->create({}); ok $row->id;