X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F72pg.t;h=5a4d162b9ebd64d4ec46b6e665f5ca566b0dcddb;hb=145b2a3d55c0b8f071364bb4f75bc9f86653725f;hp=d6cb0a9a5de0b5af99c48c5b67939146f4c2fa38;hpb=f66c9ba8c90d9ee27e4eb0ed0215d28d82dbc574;p=dbsrgits%2FDBIx-Class.git diff --git a/t/72pg.t b/t/72pg.t index d6cb0a9..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); @@ -455,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 ); @@ -472,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; @@ -489,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 @@ -519,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 ); @@ -538,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) = @_; @@ -547,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 @@ -558,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); @@ -577,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(', ', @@ -633,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(<