Hi,
thanks for this driver. I've been trying to use it with our DSN connection strings, but there seems to be some issues with ParseDSN.
According to https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-CONNSTRING values containing spaces should be quoted with single quotes. That's not supported by ParseDSN in this package. Instead it supports double quotes, but unfortunately the double quotes are included as part of the value, which then becomes invalid, at least in some cases.
Program to reproduce
package main
import (
"fmt"
"github.com/jackc/pgx"
)
func main() {
c, _ := pgx.ParseDSN(`host='foo bar' options="-c search_path=fooschema,public"`)
fmt.Printf("%s\n", c.Host)
fmt.Printf("%s\n", c.RuntimeParams["options"])
}
Expected output
foo bar
-c search_path=fooschema,public
or I suppose " isn't needed to be supported... it's not mentioned in the link above.
Actual output
'foo
"-c search_path=fooschema,public"
Yeah, that's a bug. I poked at it a little bit and it looks like completely supporting the PostgreSQL DSN format (in particular backslash escapes) would require replacing the regexp approach with a simple parser.
I can try to implement a parser instead of regexp.
Most helpful comment
I can try to implement a parser instead of regexp.