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_column():
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
classes, 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 ) = @_;
my $top = $c->model( 'Intra::User' )->search_rs({
'clients.id' => {'!=' => undef},
}, {
join => 'clients',
prefetch => 'clients',
select => [ 'id', 'username', 'first_name', 'last_name', {count =>
'clients.id'} ],
as => [ 'id', 'username', 'first_name', 'last_name', 'nr_clienti' ],
group_by => [ 'username' ],
order_by => [ {-desc => 'nr_clienti'}, {-asc => 'me.last_name'} ],
});
my $nr_contacts = $top->count;
}
When I access this action on the web, Catalyst displays the following error:
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", {
"foreign.user_id" => "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 = TB::Schema->connect(
'dbi:mysql:database=intranet;host=10.50.28.70', 'user', 'pass');
my $top = $schema->resultset( 'User' )->search_rs({
'clients.id' => {'!=' => undef},
}, {
join => 'clients',
prefetch => 'clients',
select => [ 'id', 'username', 'first_name', 'last_name', {count =>
'clients.id'} ],
as => [ 'id', 'username', 'first_name', 'last_name', 'nr_clienti' ],
group_by => [ 'username' ],
order_by => [ {-desc => 'nr_clienti'}, {-asc => 'me.last_name'} ],
});
my $nr_contacts = $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' => {
schema_class => 'TB::Schema',
connect_info => {
dsn => 'dbi:mysql:database=intranet;host=10.50.28.70',
user => 'user',
password => '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::UTF8Columns
is strongly discouraged. See documentation of DBIx::Class::UTF8Columns for more
info
Thanks.
--Octavian
------------------------------------------------------------------------------
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/