[Catalyst] Strange DBIC error, only when used in Catalyst
Octavian Rasnita
octavian.rasnita at ssifbroker.ro
Thu Sep 8 10:07:33 GMT 2011
I have forgotten to add some details about my environment.
That error was given when running the app under Catalyst's own server under=
Windows, using ActivePerl 5.10.1 and Catalyst 5.80033 with the latest DBIC.
When I ran it under Debian, it gave another error:
Couldn't render template "undef error - DBIx::Class::UTF8Columns::get_colum=
n(): No such column 'nr_contacte' at /oct/TB/root/templates/clienti/top.tt =
line 19
...that makes me think that DBIx::Class::UTF8Columns is the culprit.
It is an older app that was using that module. Is there anything I could do=
to make it work with that module?
I am afraid that if I would delete all its settings from all the Result cla=
sses, the UTF-8 chars from DB might not show correctly.
Thanks.
--Octavian
----- Original Message ----- =
From: Octavian Rasnita =
To: The elegant MVC web framework =
Sent: Thursday, September 08, 2011 12:45 PM
Subject: [Catalyst] Strange DBIC error, only when used in Catalyst
Hi all,
I have the following action:
sub top : Local {
my ( $self, $c ) =3D @_;
my $top =3D $c->model( 'Intra::User' )->search_rs({
'clients.id' =3D> {'!=3D' =3D> undef},
}, {
join =3D> 'clients',
prefetch =3D> 'clients',
select =3D> [ 'id', 'username', 'first_name', 'last_name', {count=
=3D> 'clients.id'} ],
as =3D> [ 'id', 'username', 'first_name', 'last_name', 'nr_client=
i' ],
group_by =3D> [ 'username' ],
order_by =3D> [ {-desc =3D> 'nr_clienti'}, {-asc =3D> 'me.last_na=
me'} ],
});
my $nr_contacts =3D $top->count;
}
When I access this action on the web, Catalyst displays the following err=
or:
DBIx::Class::ResultSet::count(): No such relationship clients on User at =
E:/web/TB2/script/../lib/TB/Controller/Clienti.pm line 255
But the Result class User.pm does have the clients relation:
package TB::Schema::Result::User;
...
__PACKAGE__->has_many( "clients", "TB::Schema::Result::Client", { "foreig=
n.user_id" =3D> "self.id" }, {} );
And if I use the same code outside Catalyst, it works fine and it prints =
the result:
use strict;
use lib 'lib';
use TB::Schema;
my $schema =3D TB::Schema->connect( 'dbi:mysql:database=3Dintranet;host=
=3D10.50.28.70', 'user', 'pass');
my $top =3D $schema->resultset( 'User' )->search_rs({
'clients.id' =3D> {'!=3D' =3D> undef},
}, {
join =3D> 'clients',
prefetch =3D> 'clients',
select =3D> [ 'id', 'username', 'first_name', 'last_name', {count=
=3D> 'clients.id'} ],
as =3D> [ 'id', 'username', 'first_name', 'last_name', 'nr_client=
i' ],
group_by =3D> [ 'username' ],
order_by =3D> [ {-desc =3D> 'nr_clienti'}, {-asc =3D> 'me.last_na=
me'} ],
});
my $nr_contacts =3D $top->count;
print $nr_contacts;
The model "Intra::User" is the "TB::Schema::User" class as can be seen in=
the following configuration of the app:
'Model::Intra' =3D> {
schema_class =3D> 'TB::Schema',
connect_info =3D> {
dsn =3D> 'dbi:mysql:database=3Dintranet;host=3D10.50.28.70',
user =3D> 'user',
password =3D> 'pass',
},
},
There are no other errors reported, but just a warning which I think that=
has nothing to do with that error generated by the Catalyst app:
Class::C3::Componentised::load_components(): Use of DBIx::Class::UTF8Colu=
mns is strongly discouraged. See documentation of DBIx::Class::UTF8Columns =
for more info
Thanks.
--Octavian
---------------------------------------------------------------------------=
---
_______________________________________________
List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.u=
k/
Dev site: http://dev.catalyst.perl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110908/07286=
f2a/attachment.htm
More information about the Catalyst
mailing list