Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-DBIx-Class CPAN distribution.

Report information
The Basics
Id: 112153
Status: resolved
Priority: 0/
Queue: Test-DBIx-Class

People
Owner: Nobody in particular
Requestors: pushtaev [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



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).
On Fri Feb 19 05:50:30 2016, PUSHTAEV wrote: Show quoted text
> 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).
That what fixed on GitHub: https://github.com/jjn1056/Test-DBIx-Class/pull/38