Last active
March 4, 2018 02:21
-
-
Save theory/5974a8da40562693185801b2f3569be8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/App/Sqitch/Engine/pg.pm b/lib/App/Sqitch/Engine/pg.pm | |
index 71a8d2cc..11e55ca1 100644 | |
--- a/lib/App/Sqitch/Engine/pg.pm | |
+++ b/lib/App/Sqitch/Engine/pg.pm | |
@@ -45,15 +45,22 @@ has _psql => ( | |
my $self = shift; | |
my $uri = $self->uri; | |
my @ret = ( $self->client ); | |
- for my $spec ( | |
- [ username => $self->username ], | |
- [ dbname => $uri->dbname ], | |
- [ host => $uri->host ], | |
- [ port => $uri->_port ], | |
- ) | |
- { | |
- push @ret, "--$spec->[0]" => $spec->[1] if $spec->[1]; | |
+ my @conninfo; | |
+ for (my ($k, $v) = each %{{ | |
+ username => $self->username, | |
+ dbname => $uri->dbname, | |
+ host => $uri->host, | |
+ port => $uri->_port, | |
+ $uri->query_params, | |
+ }}) { | |
+ next unless defined $v; | |
+ if ($v =~ /[ '\\]/) { | |
+ $v =~ s/(['\\])/\\$1/g; | |
+ $v = "'$v'"; | |
+ } | |
+ push @conninfo, "k=$v"; | |
} | |
+ push @ret => join ' ', @conninfo if @conninfo; | |
if (my %vars = $self->variables) { | |
push @ret => map {; '--set', "$_=$vars{$_}" } sort keys %vars; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment