[Catalyst] Using relations in catalyst

Perrin Harkins perrin at elem.com
Tue Aug 23 01:07:00 CEST 2005


On Mon, 2005-08-22 at 22:29 +0100, Matt S Trout wrote:
> On Mon, Aug 22, 2005 at 10:48:41PM +0200, Wijnand Wiersma wrote:
> > I think (no, I am sure) I don't get it yet.
> > I have to Tables: pr_ping_def and server. I have setup both with a 
> > scaffolding controller.
> > I changed M/CDBI.pm to use Catalyst::Model::CDBI::Sweet
> > and in the M/CDBI/PrPingDef.pm I have:
> > __PACKAGE__->has_a( server => 'Jabbernet::M::CDBI::Server' );
> > 
> > I updated the default template (that get's generated when you want a 
> > scaffolding table) so it only displays the server and ipaddress columns. 
> > The server is displayed as a id.
> > I want the column name of the server table to be displayed instead.
> > 
> > I tried a lot of things, at the irc channel the suggestion was to use 
> > pr_ping_def.server.name, but now it doesn't output anything.
> > 
> > Could it be a problem that the pr_ping_def table has multiple keys?
> > If so, is it possible to fix this? I cannot alter the database design.
> 
> Welcome to Class::DBI, where multi-column PKs have never worked properly
> and probably never will.

I suppose that's debatable but it doesn't sound like the problem this
guy is having is related to multi-column PKs at all, unless it's an
issue with Catalyst's scaffolding not supporting them.

A has_a relationship from a table with a multi-column key should work
fine.  What Class::DBI doesn't support is a has_a relationship TO a
table with a multi-column key.

- Perrin




More information about the Catalyst mailing list