X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F72pg.t;h=5a4d162b9ebd64d4ec46b6e665f5ca566b0dcddb;hb=0ae1217d4c8ec781f748789de447d07cc1395fbf;hp=68a52aa80d43d7b16cc8e943fb04ec2416c96967;hpb=49aa7e87a848acee321dbecde1eb139400f87bb5;p=dbsrgits%2FDBIx-Class.git diff --git a/t/72pg.t b/t/72pg.t index 68a52aa..5a4d162 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -126,9 +126,8 @@ BEGIN { use strict; use warnings; - use base 'DBIx::Class'; + use base 'DBIx::Class::Core'; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('dbic_t_schema.array_test'); __PACKAGE__->add_columns(qw/id arrayfield/); __PACKAGE__->column_info_from_storage(1); @@ -173,9 +172,8 @@ BEGIN { use strict; use warnings; - use base 'DBIx::Class'; + use base 'DBIx::Class::Core'; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('dbic_t_schema.casecheck'); __PACKAGE__->add_columns(qw/id name NAME uc_name/); __PACKAGE__->column_info_from_storage(1); @@ -271,6 +269,7 @@ done_testing; exit; END { + return unless $schema; drop_test_schema($schema); eapk_drop_all( $schema) }; @@ -454,9 +453,8 @@ BEGIN { use strict; use warnings; - use base 'DBIx::Class'; + use base 'DBIx::Class::Core'; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('apk'); @eapk_id_columns = qw( id1 id2 id3 id4 ); @@ -471,6 +469,7 @@ BEGIN { my @eapk_schemas; BEGIN{ @eapk_schemas = map "dbic_apk_$_", 0..5 } +my %seqs; #< hash of schema.table.col => currval of its (DBIC) primary key sequence sub run_extended_apk_tests { my $schema = shift; @@ -488,10 +487,18 @@ sub run_extended_apk_tests { for @eapk_schemas; $dbh->do("CREATE SEQUENCE $eapk_schemas[5].fooseq"); + $dbh->do("SELECT setval('$eapk_schemas[5].fooseq',400)"); + $seqs{"$eapk_schemas[1].apk.id2"} = 400; + $dbh->do("CREATE SEQUENCE $eapk_schemas[4].fooseq"); + $dbh->do("SELECT setval('$eapk_schemas[4].fooseq',300)"); + $seqs{"$eapk_schemas[3].apk.id2"} = 300; + $dbh->do("CREATE SEQUENCE $eapk_schemas[3].fooseq"); + $dbh->do("SELECT setval('$eapk_schemas[3].fooseq',200)"); + $seqs{"$eapk_schemas[4].apk.id2"} = 200; - $dbh->do("SET search_path = ".join ',', @eapk_schemas ); + $dbh->do("SET search_path = ".join ',', reverse @eapk_schemas ); }); # clear our search_path cache @@ -518,12 +525,14 @@ sub run_extended_apk_tests { qualify_table => 4, ); + eapk_poke( $schema ); eapk_poke( $schema, 0 ); eapk_poke( $schema, 2 ); eapk_poke( $schema, 4 ); eapk_poke( $schema, 1 ); eapk_poke( $schema, 0 ); eapk_poke( $schema, 1 ); + eapk_poke( $schema ); eapk_poke( $schema, 4 ); eapk_poke( $schema, 3 ); eapk_poke( $schema, 1 ); @@ -537,8 +546,6 @@ sub run_extended_apk_tests { # do a DBIC create on the apk table in the given schema number (which is an # index of @eapk_schemas) -my %seqs; #< sanity-check hash of schema.table.col => currval of its sequence - sub eapk_poke { my ($s, $schema_num) = @_; @@ -546,7 +553,7 @@ sub eapk_poke { ? $eapk_schemas[$schema_num] : ''; - my $schema_name_actual = $schema_name || eapk_get_search_path($s)->[0]; + my $schema_name_actual = $schema_name || eapk_find_visible_schema($s); $s->source('ExtAPK')->name($schema_name ? $schema_name.'.apk' : 'apk'); #< clear sequence name cache @@ -557,12 +564,13 @@ sub eapk_poke { lives_ok { my $new; for my $inc (1,2,3) { - $new = $schema->resultset('ExtAPK')->create({}); + $new = $schema->resultset('ExtAPK')->create({ id1 => 1}); my $proper_seqval = ++$seqs{"$schema_name_actual.apk.id2"}; is( $new->id2, $proper_seqval, "$schema_name_actual.apk.id2 correct inc $inc" ) or eapk_seq_diag($s,$schema_name); $new->discard_changes; - for my $id (grep $_ ne 'id2', @eapk_id_columns) { + is( $new->id1, 1 ); + for my $id ('id3','id4') { my $proper_seqval = ++$seqs{"$schema_name_actual.apk.$id"}; is( $new->$id, $proper_seqval, "$schema_name_actual.apk.$id correct inc $inc" ) or eapk_seq_diag($s,$schema_name); @@ -576,7 +584,7 @@ sub eapk_poke { # class sub eapk_seq_diag { my $s = shift; - my $schema = shift || eapk_get_search_path($s)->[0]; + my $schema = shift || eapk_find_visible_schema($s); diag "$schema.apk sequences: ", join(', ', @@ -632,13 +640,13 @@ sub eapk_create { local $_[1]->{Warn} = 0; my $id_def = $a{nextval} - ? "integer primary key not null default nextval('$a{nextval}'::regclass)" - : 'serial primary key'; + ? "integer not null default nextval('$a{nextval}'::regclass)" + : 'serial'; $dbh->do(<storage->dbh_do(sub { + $_[1]->selectrow_array(<