[Dbix-class] Field triggers

Jonas Alves jonas.alves at gmail.com
Mon May 7 17:17:54 GMT 2007


On 07/05/07, Pedro Melo <melo at simplicidade.org> wrote:
> Hi,
>
> This is what I want to do: when someone inserts or updates a password
> field, I want to sha1_hex'digest it.
>
> I was able to do this overriding both set_column() (for updates) and
> insert() (for inserts). Is this the best way?
>
> Should I use the inflate_column instead?
>
> Best regards,
> --
> Pedro Melo
> Blog: http://www.simplicidade.org/notes/
> Jabber ID: melo at simplicidade.org
> Use Jabber!
>

You can use DBIx::Class::DigestColumns

__PACKAGE__->load_components(qw/DigestColumns Core/);

__PACKAGE__->digestcolumns(
    columns   => [qw/password/],
    algorithm => 'SHA-1',
    encoding  => 'hex',
    dirty     => 1,
    auto      => 1,
);

-- 
Jonas



More information about the Dbix-class mailing list