diff --git a/Netdisco/Changes b/Netdisco/Changes index 1b3ac952..674fe404 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -20,6 +20,7 @@ * [#60] Incorrect format string in store_vlans (Robert Kerr) * Fix form reset icon on ports tab when using custom path (Daniel Tuecks) * Don't store failed SNMP community in the database + * [#51] Support DBD::Pg default for "host" field as local socket 2.020002 - 2013-12-11 diff --git a/Netdisco/lib/App/Netdisco.pm b/Netdisco/lib/App/Netdisco.pm index 76fff2a5..4b12f5de 100644 --- a/Netdisco/lib/App/Netdisco.pm +++ b/Netdisco/lib/App/Netdisco.pm @@ -45,14 +45,17 @@ use Dancer ':script'; if (ref {} eq ref setting('database')) { my $name = (setting('database')->{name} || 'netdisco'); - my $host = (setting('database')->{host} || 'localhost'); - my $user = (setting('database')->{user}); - my $pass = (setting('database')->{pass}); + my $host = setting('database')->{host}; + my $user = setting('database')->{user}; + my $pass = setting('database')->{pass}; + + my $dsn = "dbi:Pg:dbname=${name}"; + $dsn .= ";host=${host}" if $host; # set up the netdisco schema now we have access to the config # but only if it doesn't exist from an earlier config style setting('plugins')->{DBIC}->{netdisco} ||= { - dsn => (sprintf 'dbi:Pg:dbname=%s;host=%s', $name, $host), + dsn => $dsn, user => $user, pass => $pass, options => {