当我运行代码时:
return $self->result_source->schema->resultset('Locality')->search(
{
'addresses_view.usage' => 0
,'me.id' => $self->id
}
,{
join => { servers => 'addresses_view' }
}
);
生成的下一个sql查询:
SELECT
"me"."id", "me"."active", "me"."priority",
"me"."country_id", "me"."name"
FROM "localities" "me"
LEFT JOIN "servers" "servers" ON "servers"."locality_id" = "me"."id"
LEFT JOIN "pool_addresses_view" "addresses_view" ON "addresses_view"."server_id" = "servers"."id"
WHERE ( ( "addresses_view"."usage" = ? AND "me"."id" = ? ) )
并且执行正常。
但是当我想要将列添加到' SELECT'
时 ,'+columns' => [ 'addresses_view.ip', 'addresses_view.id' ]
我收到错误:Manual prefetch (via select/columns) not supported with accessor 'multi'
我在www.mail-archive.com/dbix-class@找到了同样的问题,但我不明白如何将columns属性传递给search_related以限制列选择
有没有办法将列添加到' SELECT'条款?
答案 0 :(得分:0)
DBIx::Class::ResultSet#prefetch只是在内部填充连接和列属性的糖。
DBIx::Class::Manual::Joining包含大量有用的信息,说明可能的内容以及应该如何回答您的问题。