]> git.donarmstrong.com Git - debbugs.git/commitdiff
allow specifying the database using the DSN
authorDon Armstrong <don@donarmstrong.com>
Mon, 29 Aug 2016 16:40:23 +0000 (09:40 -0700)
committerDon Armstrong <don@donarmstrong.com>
Mon, 29 Aug 2016 16:40:23 +0000 (09:40 -0700)
Debbugs/Config.pm
Debbugs/DB.pm
bin/debbugs-loadsql

index e0ad78eddb43069023d4acd5fdbae26d243f2763..18116314e16455511c09916b87c23c0effcf4e30 100644 (file)
@@ -1033,7 +1033,9 @@ set_default(\%config,'libravatar_blacklist',[]);
 
 =item debbugs_db
 
-Name of debbugs PostgreSQL database service
+Name of debbugs PostgreSQL database service. If you wish to not use a service
+file, provide a full DBD::Pg compliant data-source, for example:
+C<"dbi:Pg:dbname=dbname">
 
 =back
 
index c16463680d9278a7b7ed24135627bd1799487e07..313bfbb35d70b337ae9e1eca9846dc5026e711eb 100644 (file)
@@ -20,4 +20,14 @@ __PACKAGE__->load_namespaces;
 our $VERSION=2;
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
+
+# override connect to handle just passing a bare service
+sub connect {
+    my ($self,@rem) = @_;
+    if ($rem[0] !~ /:/) {
+       $rem[0] = 'dbi:Pg:service='.$rem[0];
+    }
+    $self->clone->connection(@rem);
+}
+
 1;
index 20f5722b90fa6a87e7d1be034f72de626d0d0c40..a8839e35e793c8afe8f7fa0d7a4d91e09daf648d 100755 (executable)
@@ -603,7 +603,7 @@ sub db_connect {
     my ($options) = @_;
     # connect to the database; figure out how to handle errors
     # properly here.
-    my $s = Debbugs::DB->connect('dbi:Pg:service='.$options->{service}) or
+    my $s = Debbugs::DB->connect($options->{service}) or
         die "Unable to connect to database: ";
 }