Support for whitespace in Postgres connection opts #2010

Closed
opened 2021-07-26 11:00:31 +00:00 by wbrowne · 3 comments

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 2021-07-26 13:30:14 +00:00
Author

@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 2021-07-28 02:03:09 +00:00
lunny closed this issue 2021-07-28 02:03:10 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#2010
No description provided.