From b5a7836f791c1963e448d489242d2a9a8d99860f Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Tue, 3 Jun 2014 19:46:55 -0400 Subject: [PATCH] Add oui relationship to NodeWireless result class --- .../App/Netdisco/DB/Result/NodeWireless.pm | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm b/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm index f5d2cf2b..e43244b3 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm @@ -48,6 +48,27 @@ __PACKAGE__->set_primary_key("mac", "ssid"); # Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3xsSiWzL85ih3vhdews8Hg +=head1 RELATIONSHIPS + +=head2 oui + +Returns the C table entry matching this Node. You can then join on this +relation and retrieve the Company name from the related table. + +The JOIN is of type LEFT, in case the OUI table has not been populated. + +=cut + +__PACKAGE__->belongs_to( oui => 'App::Netdisco::DB::Result::Oui', + sub { + my $args = shift; + return { + "$args->{foreign_alias}.oui" => + { '=' => \"substring(cast($args->{self_alias}.mac as varchar) for 8)" } + }; + }, + { join_type => 'LEFT' } +); =head2 node @@ -62,6 +83,8 @@ __PACKAGE__->belongs_to( node => 'App::Netdisco::DB::Result::Node', { 'foreign.mac' => 'self.mac' }, { join_type => 'LEFT' } ); +=head1 ADDITIONAL COLUMNS + =head2 net_mac Returns the C column instantiated into a L object.