From ecb5e33339ea427464f728202402a5a832eec339 Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Tue, 25 Jul 2023 12:06:52 +0200 Subject: [PATCH] Add integration test for IPv6 address in URL for SQL DBs (#4077) Add an integration test for connecting to SQL databases with an IPv6 address in a connection string. This serves as a regression test for the fix for PostgreSQL and MySQL in 1548dc15e415a2298c25af9b04f33bba3d28b998, as well as confirms that this already works on MS SQL. Ref: https://github.com/prisma/prisma-engines/pull/4051 Ref: https://github.com/prisma/prisma/issues/18079 --- .../tests/initialization/mod.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/schema-engine/sql-migration-tests/tests/initialization/mod.rs b/schema-engine/sql-migration-tests/tests/initialization/mod.rs index b19337ad3f34..81df714f445e 100644 --- a/schema-engine/sql-migration-tests/tests/initialization/mod.rs +++ b/schema-engine/sql-migration-tests/tests/initialization/mod.rs @@ -84,3 +84,28 @@ fn connecting_to_a_postgres_database_with_missing_schema_creates_it(api: TestApi assert!(schema_exists) } } + +#[test_connector(exclude(Sqlite))] +fn ipv6_addresses_are_supported_in_connection_strings(api: TestApi) { + let url = api.connection_string().replace("localhost", "[::1]"); + assert!(url.contains("[::1]")); + + let provider = api.provider(); + + let schema = format!( + r#" + datasource db {{ + provider = "{provider}" + url = "{url}" + }} + "# + ); + + let engine = schema_api(Some(schema.clone()), None).unwrap(); + tok( + engine.ensure_connection_validity(schema_core::json_rpc::types::EnsureConnectionValidityParams { + datasource: schema_core::json_rpc::types::DatasourceParam::SchemaString(SchemaContainer { schema }), + }), + ) + .unwrap(); +}