Support DBD::Pg default for "host" field as local socket

This commit is contained in:
Oliver Gorwits
2013-12-27 16:41:40 +00:00
parent d21fdf6d68
commit c9f0f21577
2 changed files with 8 additions and 4 deletions

View File

@@ -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

View File

@@ -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 => {