Eugen Konkov
Eugen Konkov

Reputation: 25223

Why DBIx column is not deflated?

I have InflateColumn defined like this

__PACKAGE__->inflate_column( request => { inflate => sub{ die },  deflate => sub{ die } } );

But when I try to store data into this column it is stored without problem.

$schema->resultset( 'Table' )->create({
    request => 'value'
});

Why is inflate/deflate not called?

Upvotes: 2

Views: 138

Answers (1)

Eugen Konkov
Eugen Konkov

Reputation: 25223

deflate will be called when value is an array reference or a hash reference

$schema->resultset( 'Table' )->create({
    request => [ 'value' ]
});

UPD The DOC

It will handle all types of references except scalar references. It will not handle scalar values, these are ignored and thus passed through to SQL::Abstract. This is to allow setting raw values to "just work". Scalar references are passed through to the database to deal with, to allow such settings as \'year + 1' and \'DEFAULT' to work.

If you want to filter plain scalar values and replace them with something else, see DBIx::Class::FilterColumn.

Upvotes: 2

Related Questions