sea-orm
sea-orm copied to clipboard
Error connecting to database with ipv6 in connection string
trafficstars
Description
I encountered an error connecting to my postgres database using connection string that uses raw ipv6 as hostname.
Steps to Reproduce
Using provided docker image, and run tests with:
DATABASE_URL="postgres://root:root@[::1]" cargo test --all --features default,sqlx-postgres,runtime-async-std-native-tls
In this case it's localhost, but I'm getting the same behavior for external hosts as well.
Expected Behavior
All tests pass.
Actual Behavior
Error encountered.
Error: Connection Error: error occurred while attempting to establish a TLS connection: invalid dns name
Caused by:
0: error occurred while attempting to establish a TLS connection: invalid dns name
1: error occurred while attempting to establish a TLS connection: invalid dns name
2: invalid dns name
Reproduces How Often
Always reproducible.
Workarounds
Modify /etc/hosts to add a domain that points to the ipv6 address, and use that domain as replacement.
Versions
v1.1.10
Expected cause
url::Url::parse() code used doesn't seem to remove the bracket from host string, causing the error.
This is similar to this issue: https://github.com/launchbadge/sqlx/pull/1818