[Dbix-class] Problem overriding connection method from Schema
module
Emmanuel Quevillon
tuco at pasteur.fr
Mon Aug 24 07:24:16 GMT 2009
-------- Original Message --------
Subject: Re: [Dbix-class] Problem overriding connection method from
Schema module
Date: Mon, 24 Aug 2009 09:23:06 +0200
From: Emmanuel Quevillon <tuco at pasteur.fr>
Reply-To: tuco at pasteur.fr
Organization: Institut Pasteur
To: Byron Young <Byron.Young at riverbed.com>
CC: 'DBIx::Class user and developer list'
<dbix-class at lists.scsys.co.uk>, "DBIx:@" <"Class
useranddeveloperlistdbix-class"@lists.scsys.co.uk>
References: <4A8E6204.6090308 at pasteur.fr>
<AFD6DC5F1927784D91384A975995D33B0198D6114314 at MAILBOXES.nbttech.com>
Byron Young wrote:
> Emmanuel Quevillon wrote on 2009-08-21:
>> sub connection {
>>
>> my ($self, @rest) = @_;
>> $self->next::method(@rest);
>>
>> $self->driver_name($self->handler()->{Driver}->{Name});
>>
>> }
>> # You can replace this text with custom content, and it will be
>> preserved on regeneration
>>
>> 1;
>>
>
> Hey Emmanuel,
>
> connection() must return the schema object (which will be returned by $self->next::method(@rest)). In this case it will actually return the driver name string instead, which explains why the interpreter chokes when it tries to call the resultset() method on a string, as in your error below.
>
Hi Byron,
Thanks to pointing me to this. It makes a lot of sense! I fixed it
and it works like a charm both from my scripts and from my Catalyst App.
>> my $schema =
>> Schema::MyAppDB->connect('dib:Pg:dbname=test','test','pass'); my $a =
>> $schema->resultset("Public"); ....
>>
>>
>> I get the following error
>>
>> Can't locate object method "resultset" via package "Pg" (perhaps you
>> forgot to load "Pg"?) at ./test.pl line 7.
>
> The Catalyst cookbook section is incorrect - it would be great for you to supply a doc patch to the catalyst list so other people don't run into this as well.
>
> Byron
>
>
Emmanuel
--
-------------------------
Emmanuel Quevillon
Biological Software and Databases Group
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr
-------------------------
--
-------------------------
Emmanuel Quevillon
Biological Software and Databases Group
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr
-------------------------
More information about the DBIx-Class
mailing list