blib/lib/App/Netdisco/DB/Result/DeviceBrowser.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 25 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use utf8;
2 package App::Netdisco::DB::Result::DeviceBrowser;
3  
4 use strict;
5 use warnings;
6  
7 use base 'App::Netdisco::DB::Result';
8 __PACKAGE__->table("device_browser");
9 __PACKAGE__->add_columns(
10 "ip",
11 { data_type => "inet", is_nullable => 0 },
12 "oid",
13 { data_type => "text", is_nullable => 0 },
14 "oid_parts",
15 { data_type => "text", is_nullable => 0 },
16 "value",
17 { data_type => "jsonb", is_nullable => 1, default_value => \q{[""]} },
18 );
19 __PACKAGE__->set_primary_key("ip", "oid");
20  
21 =head1 RELATIONSHIPS
22  
23 =head2 snmp_object
24  
25 Returns the SNMP Object table entry to which the given row is related. The
26 idea is that you always get the SNMP Object row data even if the Device
27 Browser table doesn't have any walked data.
28  
29 However you probably want to use the C<snmp_object> method in the
30 C<DeviceBrowser> ResultSet instead, so you can pass the IP address.
31  
32 =cut
33  
34 __PACKAGE__->belongs_to(
35 snmp_object => 'App::Netdisco::DB::Result::SNMPObject',
36 sub {
37 my $args = shift;
38 return {
39 "$args->{self_alias}.oid" => { -ident => "$args->{foreign_alias}.oid" },
40 "$args->{self_alias}.ip" => { '=' => \'?' },
41 };
42 },
43 { join_type => 'RIGHT' }
44 );
45  
46 __PACKAGE__->belongs_to( oid_fields => 'App::Netdisco::DB::Result::SNMPObject', 'oid', { join_type => 'left' } );
47  
48 1;