X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F72pg.t;h=d6cb0a9a5de0b5af99c48c5b67939146f4c2fa38;hb=4abde54dcba7eebe51a53071ed99e690a47541bd;hp=4a7449fbf1c9e1c431611b6d95848af6ff4e8812;hpb=52c53388b5381f9a064a9e31491ff8ce2a123990;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/72pg.t b/t/72pg.t index 4a7449f..d6cb0a9 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -271,6 +271,7 @@ done_testing; exit; END { + return unless $schema; drop_test_schema($schema); eapk_drop_all( $schema) }; @@ -476,7 +477,7 @@ sub run_extended_apk_tests { my $schema = shift; #save the search path and reset it at the end - my $search_path_save = $schema->storage->dbh_do('_get_pg_search_path'); + my $search_path_save = eapk_get_search_path($schema); eapk_drop_all($schema); @@ -546,7 +547,7 @@ sub eapk_poke { ? $eapk_schemas[$schema_num] : ''; - my $schema_name_actual = $schema_name || $s->storage->dbh_do('_get_pg_search_path')->[0]; + my $schema_name_actual = $schema_name || eapk_get_search_path($s)->[0]; $s->source('ExtAPK')->name($schema_name ? $schema_name.'.apk' : 'apk'); #< clear sequence name cache @@ -576,7 +577,7 @@ sub eapk_poke { # class sub eapk_seq_diag { my $s = shift; - my $schema = shift || $s->storage->dbh_do('_get_pg_search_path')->[0]; + my $schema = shift || eapk_get_search_path($s)->[0]; diag "$schema.apk sequences: ", join(', ', @@ -585,6 +586,25 @@ sub eapk_seq_diag { ); } +# get the postgres search path as an arrayref +sub eapk_get_search_path { + my ( $s ) = @_; + # cache the search path as ['schema','schema',...] in the storage + # obj + + return $s->storage->dbh_do(sub { + my (undef, $dbh) = @_; + my @search_path; + my ($sp_string) = $dbh->selectrow_array('SHOW search_path'); + while ( $sp_string =~ s/("[^"]+"|[^,]+),?// ) { + unless( defined $1 and length $1 ) { + die "search path sanity check failed: '$1'"; + } + push @search_path, $1; + } + \@search_path + }); +} sub eapk_set_search_path { my ($s,@sp) = @_; my $sp = join ',',@sp;