SELECT me.id,me.date_created,me.date_updated,me.yes, me.name,me.description,me.currency,me。锁定,me.skip, me.uri_part,me.user_id, 是+货币作为重量别名DBIx :: Class结果集中两列的总和
FROM我具有((重量< 5))按重量计顺序的想法;
怎样才能在DBIx ::类,查询,而无需使用文字SQL这样的:
my $query = $rs->search({},
{
'+select' => \[
'yes + currency as weight',
],
rows => 1,
order_by => { -desc => [qw/weight name/] },
having => {
weight => { '<' => $self->yes + $self->currency },
},
});
use Data::Dumper;
warn Dumper($query->as_query);
我尝试使用-as,但是,它似乎只能是有益的与生成列的工作从功能,这样的:
'+select' => {
'yes + currency', '-as' => 'weight'
}
生成错误
“匿名散列中的奇数元素 /data/TGC/lib/TGC/DB/Result/Idea.pm line 105,line 1000. DBIx :: Class :: SQLMaker :: _ recurse_fields():格式不正确的选择参数 - 太多键在哈希:标量(0xbf14c40),重”
我更新了原始查询以修复基本的SQL语法问题。最重要的是,我认为我们可能运行不同版本的SQL :: Abstract或DBIx :: Class,因为我没有得到与您一样的查询(在用您的建议子句修改原始数据后): SELECT 'me'.'id','me'.'date_created','me'.'date_updated','me'.'''','me'.'name','me'.'description','me '.'currency','me'.'locked','me'.'skip','me'.'uri_part','me'.'user_id',('me'.'yes + me'.''货币')作为'重量'从'想法''我'有'重量'<? ORDER BY'weight' DESC,'name' DESC LIMIT?) – perlDreamer
您是否在谈论引用?那是因为你已经实施了“DBI驱动程序”。我所说的** HAVING **是**在每个**数据库后端都不会被**支持。所以即使它产生了,如果你切换数据库,这可能会炸毁**。 –
@perlDreamer忘记在评论上标记你 –