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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-10277-1460548924-1831.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1547
Download (untitled) / with headers
text/plain 1.5k
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.
MIME-Version: 1.0
X-Spam-Status: No, score=-5.547 tagged_above=-99.9 required=10 tests=[AWL=0.353, BAYES_00=-1.9, FROM_OUR_RT=-4] autolearn=ham
In-Reply-To: <rt-4.0.18-10277-1460548924-179.113741-4-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-113741 [...] rt.cpan.org> <rt-4.0.18-10277-1460548924-179.113741-4-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <570E3FBA.2030606 [...] cpan.org>
content-type: text/plain; charset="utf-8"; format="flowed"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -5.547
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B0A0E240311 for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Wed, 13 Apr 2016 08:47:08 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4MEYntcB1v5V for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Wed, 13 Apr 2016 08:47:07 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 1BE1024001A for <bug-DBIx-Class [...] rt.cpan.org>; Wed, 13 Apr 2016 08:47:06 -0400 (EDT)
Received: (qmail 8839 invoked by alias); 13 Apr 2016 12:47:06 -0000
Received: from mujunyku.leporine.io (HELO mujunyku.leporine.io) (113.212.96.195) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 13 Apr 2016 05:47:03 -0700
Received: from [10.0.13.10] (unknown [10.0.13.10]) by mujunyku.leporine.io (Postfix) with ESMTP id 70AEBF4AE9 for <bug-DBIx-Class [...] rt.cpan.org>; Wed, 13 Apr 2016 12:46:52 +0000 (UTC)
Delivered-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #113741] Can't use custom HandleError with Schema::Versioned
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0
Return-Path: <ribasushi [...] cpan.org>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbix-class
Date: Wed, 13 Apr 2016 14:46:50 +0200
X-Spam-Level:
To: bug-DBIx-Class [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Peter Rabbitson <ribasushi [...] cpan.org>
RT-Message-ID: <rt-4.0.18-24492-1460551629-1885.113741-0-0 [...] rt.cpan.org>
Content-Length: 524
Download (untitled) / with headers
text/plain 524b
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.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-24492-1460551629-1885.113741-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-113741 [...] rt.cpan.org> <rt-4.0.18-10277-1460548924-179.113741-4-0 [...] rt.cpan.org> <570E3FBA.2030606 [...] cpan.org> <rt-4.0.18-24492-1460551629-1885.113741-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-16824-1460553311-42.113741-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 250
Download (untitled) / with headers
text/plain 250b
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.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-10277-1460548924-1831.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-10277-1460548924-1831.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-9890-1460623848-996.113741-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 103
Download (untitled) / with headers
text/plain 103b
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-10277-1460548924-1831.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-10277-1460548924-1831.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-8620-1466425580-1274.113741-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 67
The fix is now properly in the CPAN index. Sorry it took so long :/
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-9890-1460623848-996.113741-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-10277-1460548924-1831.0-0-0 [...] rt.cpan.org> <rt-4.0.18-9890-1460623848-996.113741-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-8587-1532430142-251.113741-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 277
Download (untitled) / with headers
text/plain 277b
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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.