[Dbix-class] Alias column names
Bill Moseley
moseley at hank.org
Tue Apr 20 15:25:14 GMT 2010
Is there a way in DBIC to alias column names? I know I can specify an
accessor name (and create wrapper accessors using different names), but I'm
looking for a way to alias column names to use both as accessors and when
calling create().
The deal is I already have a Catalyst app with a DBIx::Class model. I'm
adding some API functionality but the specifications require using new names
for some of the column data. So, in the same app I need to be able to do
$schema->resultset( 'Cd' )->create({
name =3D> 'Frampton Comes Alive',
artist =3D> $artist,
});
And
$schema->resultset( 'Cd' )->create({
ttitle =3D> 'Frampton Comes Alive',
author =3D> $artist,
});
And likewise, these are the same:
$title =3D $cd->title;
$title =3D $cd->name;
as well as these has-many relationships:
$tracks =3D $cd->tracks;
$tracks =3D $cd->songs;
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100420/349=
3e0b6/attachment.htm
More information about the DBIx-Class
mailing list