[Dbix-class] tinyint and enum mapping

jackal me at jackal.in
Thu Nov 20 09:38:41 GMT 2008


On Thursday 13 November 2008 23:24:05 Matt S Trout wrote:
> 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.htm
> > > >l
> > >
> > > 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

I'll think about it. It may be better to create a new module, which adds this 
functionality for (Inflate|Modify)Column...


-- 
Kind regards, Eugeny.



More information about the DBIx-Class mailing list