use Data::Dumper::Concise 'Dumper';
use Sub::Name 'subname';
use Try::Tiny;
-use File::Path 'mkpath';
+use File::Path 'make_path';
use namespace::clean;
__PACKAGE__->mk_group_accessors('simple' => qw/
}
unless ($self->unsafe) {
- my $weak_self = $self;
- weaken $weak_self;
- $dbh->{HandleError} = sub {
+
+ # this odd anonymous coderef dereference is in fact really
+ # necessary to avoid the unwanted effect described in perl5
+ # RT#75792
+ sub {
+ my $weak_self = $_[0];
+ weaken $weak_self;
+
+ $_[1]->{HandleError} = sub {
if ($weak_self) {
$weak_self->throw_exception("DBI Exception: $_[0]");
}
else {
# the handler may be invoked by something totally out of
# the scope of DBIC
- croak ("DBI Exception: $_[0]");
+ croak ("DBI Exception (unhandled by DBIC, ::Schema GCed): $_[0]");
}
- };
+ };
+ }->($self, $dbh);
+
$dbh->{ShowErrorStatement} = 1;
$dbh->{RaiseError} = 1;
$dbh->{PrintError} = 0;
# scope guard
my $guard = $self->txn_scope_guard;
- $self->_query_start( $sql, ['__BULK__'] );
+ $self->_query_start( $sql, [ dummy => '__BULK_INSERT__' ] );
my $sth = $self->sth($sql);
my $rv = do {
if ($empty_bind) {
}
};
- $self->_query_end( $sql, ['__BULK__'] );
+ $self->_query_end( $sql, [ dummy => '__BULK_INSERT__' ] );
$guard->commit;
carp "No directory given, using ./\n";
$dir = './';
} else {
- -d $dir or mkpath $dir
- or $self->throw_exception("create_ddl_dir: $! creating dir '$dir'");
+ -d $dir
+ or
+ make_path ("$dir") # make_path does not like objects (i.e. Path::Class::Dir)
+ or
+ $self->throw_exception(
+ "Failed to create '$dir': " . ($! || $@ || 'error unknow')
+ );
}
$self->throw_exception ("Directory '$dir' does not exist\n") unless(-d $dir);