my $DUMP_DIR = "$tdir/common_dump";
rmtree $DUMP_DIR;
+use constant RESCAN_WARNINGS => qr/(?i:loader_test)\d+ has no primary key|^Dumping manual schema|^Schema dump completed|collides with an inherited method|invalidates \d+ active statement|^Bad table or view/;
+
sub new {
my $class = shift;
my $extra_count = $self->{extra}{count} || 0;
- plan tests => @connect_info * (185 + $extra_count + ($self->{data_type_tests}{test_count} || 0));
+ plan tests => @connect_info * (181 + $extra_count + ($self->{data_type_tests}{test_count} || 0));
foreach my $info_idx (0..$#connect_info) {
my $info = $connect_info[$info_idx];
my $conn = $schema_class->clone;
$self->test_data_types($conn);
- $self->{extra}{run}->($conn, $monikers, $classes) if $self->{extra}{run};
+ $self->{extra}{run}->($conn, $monikers, $classes, $self) if $self->{extra}{run};
if (not ($ENV{SCHEMA_LOADER_TESTS_NOCLEANUP} && $info_idx == $#$connect_info)) {
$self->drop_extra_tables_only;
additional_base_classes => 'TestAdditionalBase',
left_base_classes => [ qw/TestLeftBase/ ],
components => [ qw/TestComponent/ ],
- resultset_components => [ qw/TestRSComponent/ ],
inflect_plural => { loader_test4 => 'loader_test4zes' },
inflect_singular => { fkid => 'fkid_singular' },
moniker_map => \&_monikerize,
is $file_count, $expected_count, 'correct number of files generated';
my $warn_count = 2;
- $warn_count++ if grep /ResultSetManager/, @loader_warnings;
$warn_count++ for grep /^Bad table or view/, @loader_warnings;
}
SKIP: {
- can_ok($rsobj1, 'dbix_class_testrscomponent')
- or skip "Pre-requisite test failed", 1;
- is( $rsobj1->dbix_class_testrscomponent,
- 'dbix_class_testrscomponent works',
- 'ResultSet component' );
- }
-
- SKIP: {
can_ok( $class1, 'loader_test1_classmeth' )
or skip "Pre-requisite test failed", 1;
is( $class1->loader_test1_classmeth, 'all is well', 'Class method' );
}
- SKIP: {
- can_ok( $rsobj1, 'loader_test1_rsmeth' )
- or skip "Pre-requisite test failed";
- is( $rsobj1->loader_test1_rsmeth, 'all is still well', 'Result set method' );
- }
-
ok( $class1->column_info('id')->{is_auto_increment}, 'is_auto_increment detection' );
my $obj = $rsobj1->find(1);
# relname is preserved when another fk is added
- isa_ok $rsobj3->find(1)->loader_test4zes, 'DBIx::Class::ResultSet';
+ skip 'Sybase cannot add FKs via ALTER TABLE', 2
+ if $self->{vendor} eq 'sybase';
- $conn->storage->dbh->do('ALTER TABLE loader_test4 ADD COLUMN fkid2 INTEGER REFERENCES loader_test3 (id)');
{
- local $SIG{__WARN__} = sub { warn @_
- unless $_[0] =~ /(?i:loader_test)\d+ has no primary key|^Dumping manual schema|^Schema dump completed|collides with an inherited method|invalidates \d+ active statement/
- };
- $conn->rescan;
+ local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /invalidates \d+ active statement/ };
+ $conn->storage->disconnect; # for mssql
}
+ isa_ok $rsobj3->find(1)->loader_test4zes, 'DBIx::Class::ResultSet';
+
+ $conn->storage->dbh->do('ALTER TABLE loader_test4 ADD fkid2 INTEGER REFERENCES loader_test3 (id)');
+
+ $conn->storage->disconnect; # for firebird
+
+ $self->rescan_without_warnings($conn);
+
isa_ok eval { $rsobj3->find(1)->loader_test4zes }, 'DBIx::Class::ResultSet',
'relationship name preserved when another foreign key is added in remote table';
}
sleep 1;
- my @new = do {
- local $SIG{__WARN__} = sub { warn @_
- unless $_[0] =~ /(?i:loader_test)\d+ has no primary key|^Dumping manual schema|^Schema dump completed|collides with an inherited method/
- };
- $conn->rescan;
- };
+ my @new = $self->rescan_without_warnings($conn);
+
is_deeply(\@new, [ qw/LoaderTest30/ ], "Rescan");
# system "cp t/_common_dump/DBIXCSL_Test/Schema/*.pm /tmp/after_rescan";
$conn->storage->disconnect; # for Firebird
$conn->storage->dbh->do("DROP TABLE loader_test30");
- @new = do {
- local $SIG{__WARN__} = sub { warn @_
- unless $_[0] =~ /(?i:loader_test)\d+ has no primary key|^Dumping manual schema|^Schema dump completed|collides with an inherited method/
- };
- $conn->rescan;
- };
+ @new = $self->rescan_without_warnings($conn);
+
is_deeply(\@new, [], 'no new tables on rescan');
throws_ok { $conn->resultset('LoaderTest30') }
$self->test_data_types($conn);
# run extra tests
- $self->{extra}{run}->($conn, $monikers, $classes) if $self->{extra}{run};
+ $self->{extra}{run}->($conn, $monikers, $classes, $self) if $self->{extra}{run};
$self->test_preserve_case($conn);
$conn->_loader->_setup;
- {
- local $SIG{__WARN__} = sub { warn @_
- unless $_[0] =~ /(?i:loader_test)\d+ has no primary key|^Dumping manual schema|^Schema dump completed|collides with an inherited method/
- };
- $conn->rescan;
- };
+ $self->rescan_without_warnings($conn);
if (not $self->{skip_rels}) {
is $conn->resultset('LoaderTest41')->find(1)->loader_test40->foo3_bar, 'foo',
return $test_count;
}
+sub rescan_without_warnings {
+ my ($self, $conn) = @_;
+
+ local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ RESCAN_WARNINGS };
+ return $conn->rescan;
+}
+
sub DESTROY {
my $self = shift;
unless ($ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}) {