-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sea-orm-cli
does not seem to support UNIX socket connections for PostgreSQL properly
#616
Comments
sea-orm-cli
does not seem to support UNIX socket connections properlysea-orm-cli
does not seem to support UNIX socket connections for PostgreSQL properly
Hey @maikelwever, sorry for the delay. Could you please try this? |
It works fine in SQLx or when using |
So, |
I'm using |
I think we can relax the rules here and allow UNIX socket connection sea-orm/sea-orm-cli/src/main.rs Lines 58 to 67 in e80aa07
|
Hey @maikelwever, sorry the the delay. Please check the PR I just created |
For those who trying to connect via unix socket. This works well: |
@qwuik Thank you for sharing. |
Description
When using PostgreSQL over a local UNIX socket, using peer authentication,
sea-orm-cli
refuses to connect to the database.Entering
postgres:///database_name
, should connect over the default unix socket, using local user authentication, which does not require a username, password, or hostname in the URL. Not even the database name is required, since the username is used as the default database name.Using
sea_orm::Database::connect(db_url)
this does work as expected.Steps to Reproduce
sea-orm-cli generate entity -o /tmp/ --database-url postgresql:///database_name
Expected Behavior
sea-orm-cli
connects on socket/var/run/postgresql/.s.PGSQL.5432
, using peer authentication, and generates entity code for databasedatabase_name
.Actual Behavior
sea-orm-cli
panics:thread 'main' panicked at 'No username was found in the database url', /home/maikel/.cargo/registry/src/github.com-1ecc6299db9ec823/sea-orm-cli-0.6.0/src/main.rs:62:21
Reproduces How Often
Always reproducible when using the URL given in this issue.
Versions
sea-orm-cli v0.6.0
installed globally usingcargo install
.Debian GNU/Linux 11 (Bullseye), PostgreSQL 13.
Additional Information
Sort-of works after removing the if block at https://github.com/SeaQL/sea-orm/blob/master/sea-orm-cli/src/main.rs#L59 . Still fails to accept empty database URL as well.
Because of this issue, several tests in sea-orm-cli also are expected to fail, while the URLs that are tested are sort-of valid (eg:
test_generate_entity_no_host
,test_generate_entity_no_database_section
).postgresql://root:root@localhost:3306
should attempt to connect to databaseroot
.postgres://root:root@/database
should attempt to connect to socket/var/run/postgresql/.s.PGSQL.5432
The
psql
command line tool for PostgreSQL supports URLs as the first parameter, and thus can be used to easily test if a given URL is valid.The text was updated successfully, but these errors were encountered: