# us to another table.
# OR: If is_foreign_key_constraint attr is explicity set (or set to false) on the relation
if ( ! exists $created_FK_rels{$rel_table}->{$key_test} &&
- ( exists $rel_info->{attrs}{is_foreign_key_constraint} &&
- $rel_info->{attrs}{is_foreign_key_constraint} ||
+ ( exists $rel_info->{attrs}{is_foreign_key_constraint} ?
+ $rel_info->{attrs}{is_foreign_key_constraint} :
!$source->compare_relationship_keys(\@keys, \@primary)
- )
+ )
)
{
$created_FK_rels{$rel_table}->{$key_test} = 1;
my $schema = DBICTest->init_schema;
-plan tests => 56;
+plan tests => 60;
my $translator = SQL::Translator->new(
parser_args => {
on_delete => '', on_update => '',
},
],
+ # ForceForeign
+ forceforeign => [
+ {
+ 'display' => 'forceforeign->artist',
+ 'selftable' => 'forceforeign', 'foreigntable' => 'artist',
+ 'selfcols' => ['artist'], 'foreigncols' => ['artist_id'],
+ on_delete => '', on_update => '',
+ },
+ ],
+
);
my %unique_constraints = (
);
my $tschema = $translator->schema();
-
# Test that the $schema->sqlt_deploy_hook was called okay and that it removed
# the 'link' table
ok( !defined($tschema->get_table('link')), "Link table was removed by hook");
ok( !defined($constraint), 'nonexistent FOREIGN KEY constraint not found' );
$constraint = get_constraint('UNIQUE', 'cd', ['artist']);
ok( !defined($constraint), 'nonexistent UNIQUE constraint not found' );
+$constraint = get_constraint('FOREIGN KEY', 'forceforeign', ['cd'], 'cd', ['cdid']);
+ok( !defined($constraint), 'forced nonexistent FOREIGN KEY constraint not found' );
for my $expected_constraints (keys %fk_constraints) {
for my $expected_constraint (@{ $fk_constraints{$expected_constraints} }) {
),
qw/SelfRefAlias TreeLike TwoKeyTreeLike Event EventTZ NoPrimaryKey/,
qw/Collection CollectionObject TypedObject/,
- qw/Owners BooksInLibrary/
+ qw/Owners BooksInLibrary/,
+ qw/ForceForeign/
);
sub sqlt_deploy_hook {