Support for whitespace in Postgres connection opts #2010

Closed
opened 2 months ago by wbrowne · 3 comments
wbrowne commented 2 months ago

The following inputs to the dialets.TestParsePostgres test are not supported and thus fail:

{"user='auser' password='password' dbname='db' sslmode='disable'", "db", true},
{"user='a user' password = 'password' dbname='db' sslmode='disable'", "db", true},

Given the documentation from PostgreSQL, shouldn't they be supported?

In the keyword/value format, each parameter setting is in the form keyword = value, with space(s) between settings. Spaces around a setting's equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, for example keyword = 'a value'. Single quotes and backslashes within a value must be escaped with a backslash, i.e., ' and \.

Example:

host=localhost port=5432 dbname=mydb connect_timeout=10

Is there any other possible way to support creating a Postgres connection using opts for a user containing whitespace?

IE

host=localhost port=5432 dbname=mydb connect_timeout=10 user='test user'

The following inputs to the `dialets.TestParsePostgres` test are not supported and thus fail: ``` {"user='auser' password='password' dbname='db' sslmode='disable'", "db", true}, {"user='a user' password = 'password' dbname='db' sslmode='disable'", "db", true}, ``` Given the [documentation from PostgreSQL](https://www.postgresql.org/docs/10/libpq-connect.html#LIBPQ-CONNSTRING), shouldn't they be supported? >In the keyword/value format, each parameter setting is in the form keyword = value, with space(s) between settings. Spaces around a setting's equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, for example keyword = 'a value'. Single quotes and backslashes within a value must be escaped with a backslash, i.e., \' and \\. > >Example: > >``` >host=localhost port=5432 dbname=mydb connect_timeout=10 >``` Is there any other possible way to support creating a Postgres connection *using opts* for a user containing whitespace? IE `host=localhost port=5432 dbname=mydb connect_timeout=10 user='test user'`
Owner

You can also use postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full

You can also use `postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full`
lunny added the
kind/question
label 2 months ago
Poster

@lunny is there any way to achieve this without using the URI option? I would still like to use the keyword/value format

@lunny is there any way to achieve this without using the URI option? I would still like to use the `keyword/value` format
Owner

Please confirm that #2012 fix this problem.

{"user='a user' password = 'password' dbname='db' sslmode='disable'", "db", true}, will not be supported, key should not have space followed before equal.
It should be {"user='a user' password='password' dbname='db' sslmode='disable'", "db", true},

Please confirm that #2012 fix this problem. `{"user='a user' password = 'password' dbname='db' sslmode='disable'", "db", true},` will not be supported, key should not have space followed before equal. It should be `{"user='a user' password='password' dbname='db' sslmode='disable'", "db", true},`
lunny closed this issue 2 months ago
lunny closed this issue 2 months ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.