Database 防止DBIx::Class::ResultSource预取中的Carp::Carp消息

Database 防止DBIx::Class::ResultSource预取中的Carp::Carp消息,database,perl,dbix-class,Database,Perl,Dbix Class,在客户端应用程序中,我有一个DBIx::类模型“Todo”,它可以使用多对多关系链接到许多其他模型。 我知道,由于业务逻辑,只有一个外国模型与之关联。我想在查询中使用以下方法获取该模型: my $objects = $c->model('DB')->resultset('Todo')->search($myFilter,{ prefetch => \@relations # contains all possible relations }); 与文档状态类似,

在客户端应用程序中,我有一个DBIx::类模型“Todo”,它可以使用多对多关系链接到许多其他模型。 我知道,由于业务逻辑,只有一个外国模型与之关联。我想在查询中使用以下方法获取该模型:

my $objects = $c->model('DB')->resultset('Todo')->search($myFilter,{
    prefetch => \@relations # contains all possible relations
});
与文档状态类似,DBIx::Class::ResultSource警告:

DBIx::Class::ResultSet::next(): Prefetching multiple has_many rels accountbalances_todos and accounts_todos at top level will explode the number of row objects retrievable via ->next or ->all. Use at your own risk. at /media/psf/projects/.../Controller/Todo.pm line 117
有人能告诉我如何避免这个错误而不必编辑DBIx::Class::ResultSource本身吗?我看不到其他方法可以做我想做的事情,我想防止应用程序在日志中转储大量警告。我尝试过摆弄@CARP_NOT和$CARP::Internal,但无法使CARP跳过此警告(关于此警告的文档充其量是稀疏的)


如果有人能帮助我,那就太棒了,谢谢你可以覆盖警告信号的默认处理来捕捉并忽略这个特定的警告:

$SIG{__WARN__} = sub {
  my $warn_msg = $_[0];
  if ( $warn_msg =~ m/Prefetching multiple has_many rels accountbalances_todos/ ) {
    # do nothing
  } else {
    warn $warn_msg;
  }
};
或者,如果你愿意

$SIG{__WARN__} = sub {
  warn $_[0] unless $_[0] =~ m/Prefetching multiple has_many rels accountbalances_todos/
};

DBIx::Class
使用来自
DBIx::Class::carp
模块的
carp()函数,而不是来自
carp
。所以
@CARP\u不
$CARP::Internal
不工作。相反。

谢谢大家,我成功地用上述内容消除了警告。好东西!