asyncpg icon indicating copy to clipboard operation
asyncpg copied to clipboard

Unexpected behavior when connecting to database -> Database username is used as database name.

Open healroot opened this issue 5 years ago • 1 comments

https://github.com/MagicStack/asyncpg/blob/36658fa9cff0c4910ad8c042e754ef37b23919e7/asyncpg/connect_utils.py#L390

In documentation it is said:

If not specified, the value parsed from the dsn argument is used, or the value of the PGDATABASE environment variable, or the operating system name of the user running the application.

But in fact if database username is provided but database is not, database user name is used instead of system username.

Also why not just use postgres as default value instead of username?

asyncpg version ==0.24.0 postgres: docker image postgres:13-alpine, at the moment it use version 13.4 python version ==3.8

healroot avatar Sep 06 '21 13:09 healroot

Yes, the docs are slightly incorrect, I'll make an edit.

Also why not just use postgres as default value instead of username?

For compatibility, asyncpg follows the behavior of libpq which underpins most other PostgreSQL bindings.

elprans avatar Nov 07 '21 21:11 elprans