Skip Menu |

This queue is for tickets about the CHI-Driver-DBI CPAN distribution.

Report information
The Basics
Id: 73067
Status: open
Priority: 0/
Queue: CHI-Driver-DBI

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

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



The documentation states that you can pass a sub reference as a value for the dbh parameter: 'a code reference that will be called each time and is expected to return a DBI handle, e.g.'. But it is not so. Attempting to do so will cause an error as the parameter is checked to be 'DBI::db'.
Are you sure your $dbh is valid? The script below worked for me and there is a test for it in CHI::Driver::DBI::t::CHIDriverTests::Base::test_with_dbi_generator. #!/usr/bin/perl use CHI; use DBI; use warnings; use strict; my $dbh = DBI->connect('dbi:SQLite:dbname=dbfile.db', '', ''); my $cache = CHI->new( driver => 'DBI', dbh => sub { $dbh }, create_table => 1 ); $cache->set(foo => 5); print $cache->get('foo'); On Wed Dec 07 07:54:41 2011, JIRA wrote: Show quoted text
> The documentation states that you can pass a sub reference as a value > for the dbh parameter: > > 'a code reference that will be called each time and is expected to > return a DBI handle, e.g.'. > > But it is not so. Attempting to do so will cause an error as the > parameter is checked to be 'DBI::db'.
That doesn't work for me. I get "Attribute (dbh) does not pass the type constraint because: Validation failed for 'DBI::db' with value CODE(0xa399e40) (not isa DBI::db)". So, it appears to be version dependent. I have perl 5.8.8, Moose 1.24 and CHI 0.50 Unfortunately I cannot upgrade per, Moose easily On Sat Dec 10 09:23:38 2011, JSWARTZ wrote: Show quoted text
> Are you sure your $dbh is valid? The script below worked for me and > there is a test for it in > CHI::Driver::DBI::t::CHIDriverTests::Base::test_with_dbi_generator. > > #!/usr/bin/perl > use CHI; > use DBI; > use warnings; > use strict; > > my $dbh = DBI->connect('dbi:SQLite:dbname=dbfile.db', '', ''); > my $cache = CHI->new( driver => 'DBI', dbh => sub { $dbh }, > create_table => 1 ); > $cache->set(foo => 5); > print $cache->get('foo'); > > > On Wed Dec 07 07:54:41 2011, JIRA wrote:
> > The documentation states that you can pass a sub reference as a value > > for the dbh parameter: > > > > 'a code reference that will be called each time and is expected to > > return a DBI handle, e.g.'. > > > > But it is not so. Attempting to do so will cause an error as the > > parameter is checked to be 'DBI::db'.
>
Subject: Re: [rt.cpan.org #73067]
Date: Mon, 12 Dec 2011 12:49:32 -0800
To: bug-CHI-Driver-DBI [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
It's almost certainly Moose, not Perl. That's surprising though, I would think that type coercions would work in that version of Moose. Anyway you can certainly hack in this support pretty easily. Sorry for the inconvenience. Jon On Dec 12, 2011, at 2:53 AM, Jiří Pavlovský via RT wrote: Show quoted text
> Queue: CHI-Driver-DBI > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73067 > > > That doesn't work > for me. > > I get "Attribute (dbh) does not pass the type constraint because: > Validation failed for 'DBI::db' with value CODE(0xa399e40) (not isa > DBI::db)". > > So, it appears to be version dependent. > I have perl 5.8.8, Moose 1.24 and CHI 0.50 > > Unfortunately I cannot upgrade per, Moose easily > > > On Sat Dec 10 09:23:38 2011, JSWARTZ wrote:
>> Are you sure your $dbh is valid? The script below worked for me and >> there is a test for it in >> CHI::Driver::DBI::t::CHIDriverTests::Base::test_with_dbi_generator. >> >> #!/usr/bin/perl >> use CHI; >> use DBI; >> use warnings; >> use strict; >> >> my $dbh = DBI->connect('dbi:SQLite:dbname=dbfile.db', '', ''); >> my $cache = CHI->new( driver => 'DBI', dbh => sub { $dbh }, >> create_table => 1 ); >> $cache->set(foo => 5); >> print $cache->get('foo'); >> >> >> On Wed Dec 07 07:54:41 2011, JIRA wrote:
>>> The documentation states that you can pass a sub reference as a value >>> for the dbh parameter: >>> >>> 'a code reference that will be called each time and is expected to >>> return a DBI handle, e.g.'. >>> >>> But it is not so. Attempting to do so will cause an error as the >>> parameter is checked to be 'DBI::db'.
>>
> > >
On Mon Dec 12 15:49:43 2011, swartz@pobox.com wrote: Show quoted text
> It's almost certainly Moose, not Perl. That's surprising though, I > would think that type coercions would work in that version of Moose. > > Anyway you can certainly hack in this support pretty easily.
Yeah, I did already ;) So just mention it in documentation, I'd think
Subject: Re: [rt.cpan.org #73067]
Date: Fri, 16 Dec 2011 16:50:01 -0800
To: bug-CHI-Driver-DBI [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
On Dec 12, 2011, at 2:36 PM, Jiří Pavlovský via RT wrote: Show quoted text
> Queue: CHI-Driver-DBI > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73067 > > > On Mon Dec 12 15:49:43 2011, swartz@pobox.com wrote:
>> It's almost certainly Moose, not Perl. That's surprising though, I >> would think that type coercions would work in that version of Moose. >> >> Anyway you can certainly hack in this support pretty easily.
> Yeah, I did already ;) > > So just mention it in documentation, I'd think
Sorry one more thing - what version of CHI::Driver::DBI are you using? Still hard for me to believe this isn't working. Jon
On Fri Dec 16 19:50:11 2011, swartz@pobox.com wrote: Show quoted text
> > Sorry one more thing - what version of CHI::Driver::DBI are you using? > Still hard for me to believe this isn't working.
version 1.2
Subject: Re: [rt.cpan.org #73067]
Date: Thu, 29 Dec 2011 12:48:10 -0800
To: bug-CHI-Driver-DBI [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
On Dec 28, 2011, at 12:12 PM, Jiří Pavlovský via RT wrote: Show quoted text
> Queue: CHI-Driver-DBI > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73067 > > > On Fri Dec 16 19:50:11 2011, swartz@pobox.com wrote: >
>> >> Sorry one more thing - what version of CHI::Driver::DBI are you using? >> Still hard for me to believe this isn't working.
> > version 1.2
You mean version 1.20? The feature you mention wasn't introduced until 1.22.
On Thu Dec 29 15:48:20 2011, swartz@pobox.com wrote: Show quoted text
> > On Dec 28, 2011, at 12:12 PM, Jiří Pavlovský via RT wrote: >
> > Queue: CHI-Driver-DBI > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73067 > > > > > On Fri Dec 16 19:50:11 2011, swartz@pobox.com wrote: > >
> >> > >> Sorry one more thing - what version of CHI::Driver::DBI are you using? > >> Still hard for me to believe this isn't working.
> > > > version 1.2
> > You mean version 1.20? The feature you mention wasn't introduced until
1.22. Eh, I feel like an idiot now ... Your right, I just upgraded and it works. I don't know, I somehow remembered that I installed it recently and thought I have the most recent version. Sorry about this.
Subject: Re: [rt.cpan.org #73067]
Date: Fri, 30 Dec 2011 06:26:28 -0800
To: bug-CHI-Driver-DBI [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
On Dec 30, 2011, at 2:53 AM, Jiří Pavlovský via RT wrote: Show quoted text
> Queue: CHI-Driver-DBI > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73067 > > > On Thu Dec 29 15:48:20 2011, swartz@pobox.com wrote:
>> >> On Dec 28, 2011, at 12:12 PM, Jiří Pavlovský via RT wrote: >>
>>> Queue: CHI-Driver-DBI >>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73067 > >>> >>> On Fri Dec 16 19:50:11 2011, swartz@pobox.com wrote: >>>
>>>> >>>> Sorry one more thing - what version of CHI::Driver::DBI are you using? >>>> Still hard for me to believe this isn't working.
>>> >>> version 1.2
>> >> You mean version 1.20? The feature you mention wasn't introduced until
> 1.22. > > > Eh, I feel like an idiot now ... > Your right, I just upgraded and it works. > I don't know, I somehow remembered that I installed it recently and > thought I have the most recent version. > > Sorry about this. >
:) No problem, always glad when there's an easy fix.