On Sun, May 18, 2008 at 01:19:06PM +0100, [EMAIL PROTECTED] wrote:
> Hi,
> 
> I've been unsuccessful in creating an accessor alias for a column in a
> many-to-one joined table. Here's my simplified schema defs:
> 
> package Track;
> 
> use base qw/DBIx::Class/;
> 
> __PACKAGE__->load_components(qw/UUIDColumns PK::Auto UTF8Columns Core/);
> __PACKAGE__->table('track');
> __PACKAGE__->resultset_class('DBIx::Class::ResultSet::Data::Pageset');
> __PACKAGE__->add_columns(qw/id name/);
> __PACKAGE__->set_primary_key(qw/id/);
> __PACKAGE__->uuid_columns(qw/id/);
> __PACKAGE__->uuid_class('::Data::UUID');
> __PACKAGE__->utf8_columns(qw/name/);
> 
> __PACKAGE__->has_many(trackdescriptions => 'TrackDescription', 'track_id');

> __PACKAGE__->add_columns('trackdescriptions.description' => { accessor =>
> 'description' });

This line is complete bollocks. add_columns if for columns on -your- table.

Also, if the rel is really a has_many, then you can't add an accessor anyway
since there could be more than one. 

If it was a belongs_to, then you could just write

sub description { shift->track_description->description }

or pass the 'proxy' relationship attribute to your belongs_to definition.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to