[Dbix-class] tinyint and enum mapping
Matt S Trout
dbix-class at trout.me.uk
Thu Nov 13 20:24:05 GMT 2008
On Thu, Oct 30, 2008 at 10:45:16AM +0300, jackal wrote:
> On Tuesday 28 October 2008 03:05:48 Matt S Trout wrote:
> > > Module I want to contribute, ModifyColumn, can do it:
> > >
> > > my @status = qw/ok banned warned something else/;
> > > __PACKAGE__->modify_column('status', {
> > > inflate => sub { $status[$_[0]] },
> > > deflate => sub {
> > > my $value = shift;
> > > for (my $i=0; $i<=$#status; $i++) {
> > > return $i if $status[$i] eq $value;
> > > }
> > > return undef;
> > > }
> > > });
> > >
> > > http://lists.scsys.co.uk/pipermail/dbix-class/2008-October/006968.html
> >
> > Be nice if you could handle >1 value and >1 actual column - the biggest
> > annoyance of inflate_column has been the limitation of 1 column and 1
> > attribute.
>
> I don't clearly understand what you mean. Can you give an example of desired
> interface?
>
> Now I'm doing like this:
> foreach my $c (qw/col1 col2 col3/) {
> __PACKAGE__->modify_column($c, {...});
> }
Something that would for e.g. create a $obj->full_name out of 'first_name'
and 'last_name' columns - or vice versa, thwere there's a full_name column
but we actually want $obj->first_name and $obj->last_name
--
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/
More information about the DBIx-Class
mailing list