Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: colin.newell [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.08126
Fixed in: 0.08191



Subject: DBIx::Class doesn't ensure the class is loaded when you specify cursor_class in your connection info.
If I specify a connection like this with a cursor class, my $schema = SchemaClass->connect( $dsn, $user, $pass, { cursor_class => 'DBIx::Class::Cursor::Cached' } ); If I don't have the class loaded in my schema then when I come to use it I get a complaint that the class isn't loaded. t/zzzzzzz_cursor_load.t .. Can't locate object method "new" via package "DBIx::Class::Cursor::Cached" (perhaps you forgot to load "DBIx::Class::Cursor::Cached"?) at /home/colin/git/DBIx- Class/lib/DBIx/Class/Storage/DBI.pm line 2171. I've created half a test (attached). In order to make the test work (apart from making cursor_class load the class) you'd need to include a local copy of DBIx::Class::Cursor::Cached in t/lib.
Subject: zzzzzzz_cursor_load.t
use strict; use warnings; use Test::More; use lib qw(t/lib); use DBICTest; my $schema = DBICTest->init_schema(cursor_class => 'DBIx::Class::Cursor::Cached'); my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); is(@art, 3, "Three artists returned"); done_testing;
On Sat Jan 15 02:39:59 2011, http://colinnewell.wordpress.com/ wrote: Show quoted text
> If I specify a connection like this with a cursor class, > > my $schema = SchemaClass->connect( > $dsn, $user, $pass, { cursor_class => 'DBIx::Class::Cursor::Cached' > } > ); > > If I don't have the class loaded in my schema then when I come to use it > I get a complaint that the class isn't loaded.
Here is a dump of what I wrote to the wrong person as far as proper solution to this problem (it's easy, just tedious): <ribasushi> ah right the loading thingy <ribasushi> are you familiar with Class::Accessor::Grouped? <ribasushi> it has a get/set_component_class built-in <ribasushi> which does exactly what you want (though in a retarded way, we'll get to that) <ribasushi> so all you have to do is look around dbic and grep for all inherited accessors that hold classes <ribasushi> and switch them to component_class instead <ribasushi> the retarded part is that the default get/set combo in CAG loads the class on set, whereas it ought to do it on first get instead (with a quick check in INC or whatever to short circuit) <ribasushi> rationale being - the fact that you did set the class name doesn't mean something down the road won't override it without ever using it - hence a require would be daft <ribasushi> that can be switched by simply providing our own versions of the get/set in DBIx::Class itself (through which everything else inherits CAG parts) <ribasushi> sensible? Please catch me on irc if anything is unclear. Show quoted text
> t/zzzzzzz_cursor_load.t .. Can't locate object method "new" via package
Also please do not use the zzzz suffix - it is reserved for stuff that "needs to run last". Make a t/storage/cursor.t instead. Cheers
patched in http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx- Class.git;a=commit;h=db29433c74a98967f61f117bd508c06055db2892 and http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx- Class.git;a=commit;h=6f7a118e7728040e015699975dafde1a1fb81538 On Sun Jan 16 18:06:56 2011, RIBASUSHI wrote: Show quoted text
> On Sat Jan 15 02:39:59 2011, http://colinnewell.wordpress.com/ wrote:
> > If I specify a connection like this with a cursor class, > > > > my $schema = SchemaClass->connect( > > $dsn, $user, $pass, { cursor_class =>
'DBIx::Class::Cursor::Cached' Show quoted text
> > } > > ); > > > > If I don't have the class loaded in my schema then when I come to
use it Show quoted text
> > I get a complaint that the class isn't loaded.
> > Here is a dump of what I wrote to the wrong person as far as proper > solution to this problem (it's easy, just tedious): > > <ribasushi> ah right the loading thingy > <ribasushi> are you familiar with Class::Accessor::Grouped? > <ribasushi> it has a get/set_component_class built-in > <ribasushi> which does exactly what you want (though in a retarded
way, Show quoted text
> we'll get to that) > <ribasushi> so all you have to do is look around dbic and grep for all > inherited accessors that hold classes > <ribasushi> and switch them to component_class instead > <ribasushi> the retarded part is that the default get/set combo in CAG > loads the class on set, whereas it ought to do it on first get instead > (with a quick check in INC or whatever to short circuit) > <ribasushi> rationale being - the fact that you did set the class name > doesn't mean something down the road won't override it without ever > using it - hence a require would be daft > <ribasushi> that can be switched by simply providing our own versions
of Show quoted text
> the get/set in DBIx::Class itself (through which everything else > inherits CAG parts) > <ribasushi> sensible? > > Please catch me on irc if anything is unclear. >
> > t/zzzzzzz_cursor_load.t .. Can't locate object method "new" via
package Show quoted text
> > Also please do not use the zzzz suffix - it is reserved for stuff that > "needs to run last". Make a t/storage/cursor.t instead. > > Cheers
Released in 0.08191