From dbb880a142da98b7e66e58b5d5cd82b2cba737a1 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 19 Feb 2012 15:59:03 +0000 Subject: [PATCH] remove unecessary distinct from device searches, and fix bug in by_field --- Netdisco/lib/Netdisco/DB/ResultSet/Device.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Netdisco/lib/Netdisco/DB/ResultSet/Device.pm b/Netdisco/lib/Netdisco/DB/ResultSet/Device.pm index 0248c912..0ef37f74 100644 --- a/Netdisco/lib/Netdisco/DB/ResultSet/Device.pm +++ b/Netdisco/lib/Netdisco/DB/ResultSet/Device.pm @@ -123,7 +123,7 @@ sub search_by_field { # this is a bit of an inelegant trick to catch junk data entry, # whilst avoiding returning *all* entries in the table - if (exists $p->{ip} and defined $p->{ip} and 'NetAddr::IP::Lite' ne ref $p->{ip}) { + if (length $p->{ip} and 'NetAddr::IP::Lite' ne ref $p->{ip}) { $p->{ip} = ( NetAddr::IP::Lite->new($p->{ip}) || NetAddr::IP::Lite->new('255.255.255.255') ); } @@ -161,8 +161,7 @@ sub search_by_field { }, { order_by => [qw/ me.dns me.ip /], - join => 'device_ips', - distinct => 1, + (($p->{dns} or $p->{ip}) ? (join => 'device_ips') : ()), } ); } @@ -234,7 +233,6 @@ sub search_fuzzy { { order_by => [qw/ me.dns me.ip /], join => 'device_ips', - distinct => 1, } ); }