pgx icon indicating copy to clipboard operation
pgx copied to clipboard

Add a new example usage that reminds the user to utilize the escape method for the connection string

Open karminski opened this issue 1 year ago • 2 comments

For certain Golang database driver libraries, such as go-sql-driver the connection string is automatically escaped by the library itself. Therefore, I believe it is crucial to inform users whether the connection string requires escaping or not.

karminski avatar Feb 05 '24 05:02 karminski

~~The example would no longer represent idiomatic usage. If the application is has the host, user name, password, etc. individually then it should call pgx.ParseConfig("") and manually set the fields on the returned *pgx.ConnConfig. In this case, the password would not need to be escaped.~~

jackc avatar Feb 06 '24 01:02 jackc

I think that adding a note to the ParseConfig function to this effect would be better. Possible the note would simply mention that URLs are parsed by the Go standard URL parser and must be properly escaped.

jackc avatar Feb 06 '24 01:02 jackc