Error connecting to database with ipv6 in connection string
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
Hi! Is the bug still open? I could try to solve it.
Thanks!
I don't know if it still exists, but I haven't seen any PRs about this issue.
Currently the tests for async-std seem to be broken, I got this with tokio.
thread 'main' panicked at tests/common/setup/mod.rs:36:48:
called `Result::unwrap()` on an `Err` value: Conn(SqlxError(Io(Os { code: 97, kind: Uncategorized, message: "Address family not supported by protocol" })))