Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 66630
Status: rejected
Priority: 0/
Queue: DBIx-Connector

People
Owner: Nobody in particular
Requestors: nomad [...] null.net
Cc:
AdminCc:

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



Subject: Callback handles are not passed to DBIx::Connector callers
Date: Tue, 15 Mar 2011 22:15:18 +1300
To: bug-DBIx-Connector [...] rt.cpan.org
From: Mark Lawrence <nomad [...] null.net>
I'm trying to use the on-connect call-back functionality DBI provides by specifying a subroutine in the {Callbacks}->{connected} part of the DBI->connect attributes hash. The issue I seem to be seeing is that the handle that is passed to the anonymous subroutine specified in that hash is not the same handle that DBIX::Connector is providing to callers. The attached test checks to see if that is in fact the case, and currently fails with the latest version. For me this means I can't automatically set things like the SQLite foreign_key pragma at the very beginning of my session. Mark. -- Mark Lawrence

Message body is not shown because sender requested not to inline it.

CC: Tim Bunce <Tim.Bunce [...] pobox.com>
Subject: Re: [rt.cpan.org #66630] Callback handles are not passed to DBIx::Connector callers
Date: Tue, 15 Mar 2011 11:42:00 -0700
To: bug-DBIx-Connector [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
On Mar 15, 2011, at 3:01 AM, Mark Lawrence via RT wrote: Show quoted text
> I'm trying to use the on-connect call-back functionality DBI provides > by specifying a subroutine in the {Callbacks}->{connected} part of the > DBI->connect attributes hash. > > The issue I seem to be seeing is that the handle that is passed to the > anonymous subroutine specified in that hash is not the same handle that > DBIX::Connector is providing to callers. The attached test checks to see if > that is in fact the case, and currently fails with the latest version. > > For me this means I can't automatically set things like the SQLite > foreign_key pragma at the very beginning of my session.
Interesting. I use those callbacks myself and they work fine. However, I see what you mean, but it appears to be a DBI issue. This test fails, too. #!/usr/bin/perl use strict; use warnings; use Test::More; use Test::Database; use DBI; my $subs; my @handles = Test::Database->handles(qw/ SQLite Pg mysql /); if (@handles) { plan tests => 1 * @handles; } else { plan skip_all => "No database handles to test with"; } foreach my $handle (@handles) { my ( $dsn, $user, $pass ) = $handle->connection_info; my $callback_dbh; my $conn = DBI->connect( $handle->connection_info, { PrintError => 0, RaiseError => 1, Callbacks => { connected => sub { my $h = shift; $callback_dbh = $h; return; }, } }, ); is $conn, $callback_dbh; } done_testing(); 1; I think you should ask on the DBI list about this. Best, David
Subject: Re: [rt.cpan.org #66630] Callback handles are not passed to DBIx::Connector callers
Date: Wed, 16 Mar 2011 08:54:42 +1300
To: David Wheeler via RT <bug-DBIx-Connector [...] rt.cpan.org>
From: Mark Lawrence <nomad [...] null.net>
On Tue Mar 15, 2011 at 02:42:09PM -0400, David Wheeler via RT wrote: Show quoted text
> Interesting. I use those callbacks myself and they work fine. > However, I see what you mean, but it appears to be a DBI issue. This > test fails, too. > > #!/usr/bin/perl > > [ test with DBI instead of DBIx::Connector snipped ]
I ran a similar test after I opened the report and discovered the same thing. Then I ran a test (with DBIx::Connector) that set the SQLite foreign_keys pragma in the callback (which my original code was supposed to be doing), and retrieved it afterwards, which works as advertised. Going back to my original code it turns out I hadn't spelt the pragma correctly. Unfortunately SQLite doesn't complain in that case. So that fact that DBI changes the handle underneath is most likely by design, and this report was noise. *sigh* It is not easy to get things right. Thanks anyway for the quick response. Mark. -- Mark Lawrence
On Tue Mar 15 15:55:03 2011, nomad@null.net wrote: Show quoted text
> Going back to my original code it turns out I hadn't spelt the pragma > correctly. Unfortunately SQLite doesn't complain in that case. > > So that fact that DBI changes the handle underneath is most likely by > design, and this report was noise. > > *sigh* It is not easy to get things right.
No worries, I've been nailed by spelling errors many times myself. :-) David