sub run_tests {
my $self = shift;
- plan tests => 88;
+ plan tests => 101;
$self->create();
my $warn_count = 0;
$warn_count++ if grep /ResultSetManager/, @loader_warnings;
+ $warn_count++ if grep /Dynamic schema detected/, @loader_warnings;
+ $warn_count++ for grep /^Bad table or view/, @loader_warnings;
if($self->{skip_rels}) {
is(scalar(@loader_warnings), $warn_count)
can_ok( $class1, 'dbix_class_testcomponent' ) or $skip_tcomp = 1;
can_ok( $class1, 'loader_test1_classmeth' ) or $skip_cmeth = 1;
- TODO: {
- local $TODO = "Not yet supported by ResultSetManger code";
- can_ok( $rsobj1, 'loader_test1_rsmeth' ) or $skip_rsmeth = 1;
- }
+ can_ok( $rsobj1, 'loader_test1_rsmeth' ) or $skip_rsmeth = 1;
SKIP: {
skip "Pre-requisite test failed", 1 if $skip_tab;
is( $obj2->id, 2 );
SKIP: {
- skip $self->{skip_rels}, 50 if $self->{skip_rels};
+ skip $self->{skip_rels}, 63 if $self->{skip_rels};
my $moniker3 = $monikers->{loader_test3};
my $class3 = $classes->{loader_test3};
my $rs_rel4 = $obj3->search_related('loader_test4zes');
isa_ok( $rs_rel4->first, $class4);
+ # test that _id is not stripped and prepositions in rel names are
+ # ignored
+ ok ($rsobj4->result_source->has_relationship('loader_test5_to_ids'),
+ "rel with preposition 'to' and _id pluralized backward-compatibly");
+
+ ok ($rsobj4->result_source->has_relationship('loader_test5_from_ids'),
+ "rel with preposition 'from' and _id pluralized backward-compatibly");
+
+ # check that default relationship attributes are not applied in 0.04006 mode
+ is $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{cascade_delete}, 1,
+ 'cascade_delete => 1 on has_many by default';
+
+ is $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{cascade_copy}, 1,
+ 'cascade_copy => 1 on has_many by default';
+
+ ok ((not exists $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{on_delete}),
+ 'has_many does not have on_delete');
+
+ ok ((not exists $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{on_update}),
+ 'has_many does not have on_update');
+
+ ok ((not exists $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{is_deferrable}),
+ 'has_many does not have is_deferrable');
+
+ isnt $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{on_delete}, 'CASCADE',
+ "on_delete => 'CASCADE' not on belongs_to by default";
+
+ isnt $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{on_update}, 'CASCADE',
+ "on_update => 'CASCADE' not on belongs_to by default";
+
+ isnt $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{is_deferrable}, 1,
+ "is_deferrable => 1 not on belongs_to by default";
+
+ ok ((not exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{cascade_delete}),
+ 'belongs_to does not have cascade_delete');
+
+ ok ((not exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{cascade_copy}),
+ 'belongs_to does not have cascade_copy');
+
# find on multi-col pk
my $obj5 = $rsobj5->find({id1 => 1, id2 => 1});
is( $obj5->id2, 1 );
}
SKIP: {
- skip 'This vendor cannot do inline relationship definitions', 5
+ skip 'This vendor cannot do inline relationship definitions', 6
if $self->{no_inline_rels};
my $moniker12 = $monikers->{loader_test12};
isa_ok( $obj13->id, $class12 );
isa_ok( $obj13->loader_test12, $class12);
isa_ok( $obj13->dat, $class12);
+
+ my $obj12 = $rsobj12->find(1);
+ isa_ok( $obj12->loader_test13_ids, "DBIx::Class::ResultSet" );
}
SKIP: {
q{ INSERT INTO loader_test30 (id,loader_test2) VALUES(321, 2) },
);
- my $dbh = $self->dbconnect(1);
- $dbh->do($_) for @statements_rescan;
- $dbh->disconnect;
+ {
+ my $dbh = $self->dbconnect(1);
+ $dbh->do($_) for @statements_rescan;
+ $dbh->disconnect;
+ }
- my @new = $conn->rescan;
+ my @new = do {
+ local $SIG{__WARN__} = sub {};
+ $conn->rescan;
+ };
is(scalar(@new), 1);
is($new[0], 'LoaderTest30');
AutoCommit => 1,
}
);
+ if ($self->{dsn} =~ /^[^:]+:SQLite:/) {
+ $dbh->do ('PRAGMA synchronous = OFF');
+ }
+ elsif ($self->{dsn} =~ /^[^:]+:Pg:/) {
+ $dbh->do ('SET client_min_messages=WARNING');
+ }
die "Failed to connect to database: $DBI::errstr" if !$dbh;
id1 INTEGER NOT NULL,
iD2 INTEGER NOT NULL,
dat VARCHAR(8),
- PRIMARY KEY (id1,id2)
+ from_id INTEGER,
+ to_id INTEGER,
+ PRIMARY KEY (id1,id2),
+ FOREIGN KEY (from_id) REFERENCES loader_test4 (id),
+ FOREIGN KEY (to_id) REFERENCES loader_test4 (id)
) $self->{innodb}
},
my $dbh = $self->dbconnect(1);
- # Silence annoying but harmless postgres "NOTICE: CREATE TABLE..."
- local $SIG{__WARN__} = sub {
- my $msg = shift;
- print STDERR $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
- };
-
$dbh->do($_) for (@statements);
unless($self->{skip_rels}) {
# hack for now, since DB2 doesn't like inline comments, and we need