X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F72pg.t;h=d676812c5d89888ab219da073ac44bb1c9fef7ab;hb=494b5561c3df99acd3b52a8ad320669b93b7f90e;hp=4065b260e55f181d78a666885c7b42d6ed5c3bd2;hpb=1f5aae08362fffa1fcf0991909293d9c418e1c40;p=dbsrgits%2FDBIx-Class.git diff --git a/t/72pg.t b/t/72pg.t index 4065b26..d676812 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -23,16 +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 $schema; - -require DBIx::Class::Storage::DBI::Pg; +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 $can_insert_returning = - DBIx::Class::Storage::DBI::Pg->can('can_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/; - local *DBIx::Class::Storage::DBI::Pg::can_insert_returning = sub { + local *DBIx::Class::Storage::DBI::Pg::_supports_insert_returning = sub { $use_insert_returning }; @@ -69,13 +73,6 @@ for my $use_insert_returning (0..1) { $schema = DBICTest::Schema->connect($dsn, $user, $pass); $schema->storage->ensure_connected; - if ($use_insert_returning && (not $can_insert_returning->($schema->storage))) - { - diag "Your version of PostgreSQL does not support INSERT ... RETURNING."; - diag "*** SKIPPING FURTHER TESTS"; - last; - } - drop_test_schema($schema); create_test_schema($schema); @@ -204,6 +201,15 @@ for my $use_insert_returning (0..1) { is( $uc_name_info->{size}, 3, "Case insensitive matching info for 'uc_name'" ); +## Test ResultSet->update +my $artist = $schema->resultset('Artist')->first; +my $cds = $artist->cds_unordered->search({ + year => { '!=' => 2010 } +}, { prefetch => 'liner_notes' }); +TODO: { + todo_skip 'update resultset with a prefetch over a might_have rel', 1; + $cds->update({ year => '2010' }); +} ## Test SELECT ... FOR UPDATE @@ -241,12 +247,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; @@ -281,7 +290,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;