Subject: | drop_table_sql can't drop view |
This is the current implementation of Test::DBIx::Class::SchemaManager::drop_table_sql method:
sub drop_table_sql
{
my $self = shift;
my $table = shift;
return "drop table $table";
}
The problem is, $table is not indeed a table, it can be a view. My current workaround is to use my own trait with the following drop_table_sql implementation:
sub drop_table_sql {
my ($self, $table) = @_;
my $schema = $self->schema;
foreach my $source ($schema->sources) {
my $source_info = $schema->source($source);
if ($table eq $source_info->name) {
return "DROP VIEW $table" if (ref $source_info) =~ /::View$/;
last;
}
}
return "DROP TABLE $table";
}
Could you please fix the original implementation (you can use with the better code than mine though).