Skip Menu |

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

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

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

Bug Information
Severity: (no value)
Broken in: 0.082820
Fixed in: 0.082840



Subject: Can't use custom HandleError with Schema::Versioned
I had the following schema class (abbreviated): <pre> package My::Schema; use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces; our $VERSION = 0.007; ... sub _custom_error_handler { my ( $dbi_errstr, $dbi_handle ) = @_; # munge exception and rethrow } sub connection { # override DBIC's connection method to add custom exception # handling my ( $self, $dsn, $user, $password, $options, @rest ) = @_; # not sure cloning is really required my $options_clone = { %{ $options // {} } }; # see https://metacpan.org/pod/DBIx::Class::Storage::DBI#unsafe $options_clone->{HandleError} = \&_custom_error_handler; $options_clone->{unsafe} = 1; $self->SUPER::connection( $dsn, $user, $password, $options_clone, @rest ); } </pre> This works fine. However, if I switch to DBIx::Class::Schema::Versioned, I get the following error when calling $schema->deploy({ add_drop_table => 1 }): <pre> DBIx::Class::Storage::DBI::catch {...} (): DBI Connection failed: DBIx::Class::Storage::DBI::try {...} (): Refusing clobbering of {HandleError} installed on externally supplied DBI handle DBI::db=HASH(0xc3ee6f0). Either remove the handler or use the 'unsafe' attribute. at t/lib/BasicFixture.pm line 47 at t/lib/BasicFixture.pm line 47 </pre> This occurs right after the actual deploy, since the tables have been created, but no code after deploy() has been called. It sounds like a second dbh is created from the connection info gathered from the original, but by that time "unsafe" has been lost.
Subject: Re: [rt.cpan.org #113741] Can't use custom HandleError with Schema::Versioned
Date: Wed, 13 Apr 2016 14:46:50 +0200
To: bug-DBIx-Class [...] rt.cpan.org
From: Peter Rabbitson <ribasushi [...] cpan.org>
On 04/13/2016 02:02 PM, Fabrice Gabolde via RT wrote: Show quoted text
> It sounds like a second dbh is created from the connection info gathered from the original, but by that time "unsafe" has been lost.
This is correct. This is the spot where it happens: https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.082821/lib/DBIx/Class/Schema/Versioned.pm#L595 Check if $conn_attrs contains unsafe, and if yes - you'll need to pass it on in the call above. If it works for you - a PR with a test added to t/94versioning.t would be awesome.
On Wed, 13 Apr 2016 08:47:09 -0400, RIBASUSHI wrote: Show quoted text
> On 04/13/2016 02:02 PM, Fabrice Gabolde via RT wrote: > > Check if $conn_attrs contains unsafe
It doesn't. Show quoted text
> a PR with a test added to t/94versioning.t would be awesome.
Sure, I can do that.
The fix is now properly in the CPAN index. Sorry it took so long :/
On Thu Apr 14 04:50:48 2016, RIBASUSHI wrote: Show quoted text
> Fixed by https://github.com/dbsrgits/dbix- > class/commit/e7dcdf69fd#diff-7ec2db724e80c975475473f856913213
would be nice if 'unsafe' attribute documented cross link: https://github.com/bigpresh/Dancer-Plugin-Database/issues/57