Subject: | Document how to include attributes containing spaces in the DSN |
Date: | Thu, 17 Dec 2015 11:41:36 -0700 |
To: | bug-DBD-Pg [...] rt.cpan.org |
From: | Maxwell Carey <mcarey [...] ucar.edu> |
A user on Stack Overflow asked how to include attributes containing spaces
in the DSN: http://stackoverflow.com/q/34317892/176646
I don't normally use Postgres so I had to dig through the source to find
out that you can do this by surrounding the value with single quotes, e.g.
my $dsn = q{dbi:Pg:db=foo;host=bar;attr='thing with spaces'};
This should be added to the documentation for connect().
The docs should probably also explain how to include backslashes and single
quotes in such attributes:
# Single-quoted string
my $dsn = q{dbi:Pg:db=foo;host=bar;attr='thing with spaces \' single
quotes and \\\backslashes'};
or
# Double-quoted string
my $dsn = qq{dbi:Pg:db=foo;host=bar;attr='thing with spaces \\\' single
quotes and \\\\backslashes'};
(Although looking at the code, embedded single quotes don't appear to be
handled properly:
https://metacpan.org/source/TURNSTEP/DBD-Pg-3.5.3/dbdimp.c#L122)