Files
netdisco/lib/App/Netdisco/DB/Result/Virtual/OidChildren.pm

32 lines
821 B
Perl
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use utf8;
package App::Netdisco::DB::Result::Virtual::OidChildren;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
# NO LONGER USED BY NETDISCO
# (PostgreSQL cannot handle GROUP BY using ARRAY element where
# element ID is a bind value)
__PACKAGE__->table("oid_children");
__PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
SELECT DISTINCT(db.oid_parts[?]) AS part, count(distinct(db.oid_parts[?])) as children
FROM device_browser db
WHERE db.ip = ?
AND db.oid LIKE ? || '.%'
GROUP BY db.oid_parts[?], db.oid_parts
ENDSQL
);
__PACKAGE__->add_columns(
'part' => { data_type => 'integer' },
'children' => { data_type => 'integer' },
);
1;