From: Peter Rabbitson Date: Wed, 20 Jul 2016 12:13:49 +0000 (+0200) Subject: Fix misleading error on deployment_statements in void ctx X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a8eaf44b3d65c08780571a811059e4b43b81ef6b;p=dbsrgits%2FDBIx-Class.git Fix misleading error on deployment_statements in void ctx Due to how Context::Preserve operates the following would result in a non-sensical error: perl -MDBIx::Class::Schema -e ' DBIx::Class::Schema->connect("dbi:SQLite::memory:")->deployment_statements; 1 ' --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 474d964..fe27d47 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -23,8 +23,16 @@ use mro 'c3'; use base qw/DBIx::Class::Componentised DBIx::Class::AccessorGroup/; use DBIx::Class::Exception; -__PACKAGE__->mk_classaccessor( _skip_namespace_frames => - '^DBIx::Class|^SQL::Abstract|^Try::Tiny|^Class::Accessor::Grouped|^Context::Preserve|^Moose::Meta::' +__PACKAGE__->mk_classaccessor( + _skip_namespace_frames => join( '|', map { '^' . $_ } qw( + DBIx::Class + SQL::Abstract + SQL::Translator + Try::Tiny + Class::Accessor::Grouped + Context::Preserve + Moose::Meta:: + )), ); sub component_base_class { 'DBIx::Class' } diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 132c8d4..2734385 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -3107,6 +3107,11 @@ See L for a list of values for C<$sqlt_args>. sub deployment_statements { my ($self, $schema, $type, $version, $dir, $sqltargs) = @_; + + $self->throw_exception( + 'Calling deployment_statements() in void context makes no sense' + ) unless defined wantarray; + $type ||= $self->sqlt_type; $version ||= $schema->schema_version || '1.x'; $dir ||= './';