[Dbix-class] Extra columns in data for update/create

Jason Kohles email at jasonkohles.com
Fri Mar 13 02:59:17 GMT 2009


On Mar 12, 2009, at 10:22 PM, Trevor Phillips wrote:

> Is there an easy and efficient way to either tell methods like create
> to ignore extra columns passed in, or to filter %Data to only include
> columns in the table?
>
I don't know about efficient, but this is how I do it...

package MyApp::DB::Result;
use parent 'DBIx::Class';
# ...
sub absorb {
     my ( $self, $in ) = @_;

     $self->update( {
         map { ( $_ => $in->{ $_ } ) }
         grep { $self->has_column( $_ ) }
         keys %{ $in }
     } );
}

-- 
Jason Kohles, RHCA RHCDS RHCE
email at jasonkohles.com - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire





More information about the DBIx-Class mailing list