我有这样定义的InflateColumn
__PACKAGE__->inflate_column( request => { inflate => sub{ die }, deflate => sub{ die } } );
但是当我尝试将数据存储到此列时,它的存储没有问题。
$schema->resultset( 'Table' )->create({
request => 'value'
});
为什么不调用inflate/deflate
?
最佳答案
当 value
是数组引用或哈希引用时,将调用 deflate
$schema->resultset( 'Table' )->create({
request => [ 'value' ]
});
UPDDOC
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.
关于perl - 为什么 DBIx 柱没有放气?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41649380/