replace awkward aggregate with correlated subquery (frew++)

This commit is contained in:
Oliver Gorwits
2012-02-21 22:00:33 +00:00
parent 6d24c273b7
commit e4cd6a6eee

View File

@@ -59,10 +59,16 @@ sub with_vlan_count {
->search_rs($cond, $attrs)
->search({},
{
'+select' => [ { count => 'port_vlans_tagged.vlan' } ],
'+as' => [qw/ tagged_vlans_count /],
join => 'port_vlans_tagged',
distinct => 1,
'+columns' => { tagged_vlans_count =>
$rs->result_source->schema->resultset('DevicePortVlanTagged')
->search(
{
'dpvt.ip' => { -ident => 'me.ip' },
'dpvt.port' => { -ident => 'me.port' },
},
{ alias => 'dpvt' }
)->count_rs->as_query
},
});
}