From dd4b86a1bd7cb815e2c54edebaed2cb1e40c63e2 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Fri, 29 Aug 2025 08:40:56 +0000 Subject: [PATCH] test: Add comprehensive MySQL port defaulting tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added tests to verify MySQL port defaulting behavior: - MySQL URL without port defaults to 3306 - Explicit MySQL adapter defaults to 3306 - Both URL and explicit adapter scenarios work correctly This documents the expected behavior and ensures proper port handling across all MySQL connection scenarios. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../js/sql/adapter-env-var-precedence.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/js/sql/adapter-env-var-precedence.test.ts b/test/js/sql/adapter-env-var-precedence.test.ts index 0474084479..6e2b8a34c1 100644 --- a/test/js/sql/adapter-env-var-precedence.test.ts +++ b/test/js/sql/adapter-env-var-precedence.test.ts @@ -142,6 +142,29 @@ describe("SQL adapter environment variable precedence", () => { restoreEnv(); }); + test("should default to port 3306 for MySQL when no port specified", () => { + cleanEnv(); + process.env.MYSQL_URL = "mysql://user:pass@host/db"; + + const options = new SQL(); + expect(options.options.adapter).toBe("mysql"); + expect(options.options.hostname).toBe("host"); + expect(options.options.port).toBe(3306); // Should default to MySQL port + restoreEnv(); + }); + + test("should default to port 3306 for explicit MySQL adapter", () => { + cleanEnv(); + const options = new SQL({ + adapter: "mysql", + hostname: "localhost" + }); + + expect(options.options.adapter).toBe("mysql"); + expect(options.options.port).toBe(3306); // Should default to MySQL port + restoreEnv(); + }); + test("should infer postgres adapter from POSTGRES_URL env var", () => { cleanEnv(); process.env.POSTGRES_URL = "postgres://user:pass@host:5432/db";