$tables{$table_name}{foreign_table_deps}{$rel_table}++;
}
+ # trim schema before generating constraint/index names
+ (my $table_abbrev = $table_name) =~ s/ ^ [\w\-]+ \. //x;
+
$table->add_constraint(
type => 'foreign_key',
- name => join('_', $table_name, 'fk', @keys),
+ name => join('_', $table_abbrev, 'fk', @keys),
fields => \@keys,
reference_fields => \@refkeys,
reference_table => $rel_table,
next if join("\x00", @keys) eq join("\x00", @primary);
if ($add_fk_index_rel) {
+ (my $idx_name = $table_name) =~ s/ ^ [\w\-]+ \. //x;
my $index = $table->add_index(
- name => join('_', $table_name, 'idx', @keys),
+ name => join('_', $table_abbrev, 'idx', @keys),
fields => \@keys,
type => 'NORMAL',
);
}, 'partial schema tests successful');
}
+{
+ my $cd_rsrc = $schema->source('CD');
+ $cd_rsrc->name(\'main.cd');
+
+ my $sqlt_schema = create_schema(
+ { schema => $schema },
+ args => { ignore_constraint_names => 0, ignore_index_names => 0 }
+ );
+
+ foreach my $source_name (qw(CD)) {
+ my $table = get_table($sqlt_schema, $schema, $source_name);
+ ok(
+ !(grep {$_->name =~ m/main\./} $table->get_indices),
+ 'indices have periods stripped out'
+ );
+ ok(
+ !(grep {$_->name =~ m/main\./} $table->get_constraints),
+ 'constraints have periods stripped out'
+ );
+ }
+}
+
done_testing;
sub create_schema {