perl - 为什么 DBIx 柱没有放气?

标签 perl dbix-class

我有这样定义的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/

相关文章:

perl - 修饰符在服务对象下不可见

perl - 如何漂亮地打印 DBIx::Class 结果?

mysql - DBIx 迁移无法识别 MySQL

perl - 更改 DBIx 类结果类的继承树?

arrays - 按偏移量索引 Perl 数组的速度

perl - 在 Perl 中,使用 @a[$i] 访问数组元素与使用 $a[$i] 有什么区别?

c - perlxstut 中应该有 newSVuv 而不是 newSVnv 吗?

perl - 使用 perl Archive::Zip 创建 *.epub -- epubchecker 错误

sql - 如何在 DBIx::Class 结果集搜索中检索每个组中的最新记录?

带有 Catalyst 和 DBIx::Class 的 Perl - 如何在继承树中加载一组类?