pytest-postgresql icon indicating copy to clipboard operation
pytest-postgresql copied to clipboard

Should not attempt to connect to `postgres` database in detached mode

Open zx80 opened this issue 3 years ago • 3 comments

What action do you want to perform

Use postgresql in detached mode on a standard pg account and database:

createuser pytest  # with password "pytest"
createdb -O pytest pytest
pytest --postgresql-detached --postgresql-user=pytest --postgresql-password=pytest --postgreqsl-dbname=pytest ...

What are the results

The connection fails because it attempts to connect to the postgres database. This is hardcoded here.

What are the expected results

It should use the provided dbname to get the version, and succeed.

zx80 avatar Sep 18 '22 08:09 zx80

🤔 What is the detached mode?

fizyk avatar Sep 26 '22 21:09 fizyk

Sorry, this option is added by the script. It triggers using _noproc instead of _proc, i.e. it uses an existing server where the database user does not have access to postgres, which makes sense for a non super-user database account.

Postgres command psql -l connects to postgres only if no database name is provided, so I think that the connection should do the same and use dbname or "postgres" as a database target.

zx80 avatar Sep 27 '22 06:09 zx80

related #672

fizyk avatar Nov 07 '22 15:11 fizyk