mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix(sql): correct MySQL unix socket error message
The error message when failing to connect to a MySQL database via unix socket incorrectly said "failed to connect to postgresql" instead of "failed to connect to mysql". This was a copy-paste error. Fixes #26648 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -464,7 +464,7 @@ pub fn createInstance(globalObject: *jsc.JSGlobalObject, callframe: *jsc.CallFra
|
|||||||
ptr.#connection.setSocket(.{
|
ptr.#connection.setSocket(.{
|
||||||
.SocketTCP = uws.SocketTCP.connectUnixAnon(path, ctx, ptr, false) catch |err| {
|
.SocketTCP = uws.SocketTCP.connectUnixAnon(path, ctx, ptr, false) catch |err| {
|
||||||
ptr.deref();
|
ptr.deref();
|
||||||
return globalObject.throwError(err, "failed to connect to postgresql");
|
return globalObject.throwError(err, "failed to connect to mysql");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
41
test/regression/issue/26648.test.ts
Normal file
41
test/regression/issue/26648.test.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { expect, test } from "bun:test";
|
||||||
|
import { bunEnv, bunExe, tempDir } from "harness";
|
||||||
|
|
||||||
|
test("MySQL unix socket error message should not say 'postgresql'", async () => {
|
||||||
|
using dir = tempDir("mysql-socket-test", {
|
||||||
|
"test.ts": `
|
||||||
|
import { join } from "path";
|
||||||
|
// Create a regular file (not a socket) to trigger the connection error
|
||||||
|
const fakeSockPath = join(import.meta.dirname, "fake.sock");
|
||||||
|
await Bun.write(fakeSockPath, "");
|
||||||
|
|
||||||
|
const conn = new Bun.SQL({
|
||||||
|
adapter: 'mysql',
|
||||||
|
path: fakeSockPath,
|
||||||
|
username: 'root',
|
||||||
|
database: 'test'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await conn\`select 1\`;
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e.message);
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
await using proc = Bun.spawn({
|
||||||
|
cmd: [bunExe(), "test.ts"],
|
||||||
|
env: bunEnv,
|
||||||
|
cwd: String(dir),
|
||||||
|
stdout: "pipe",
|
||||||
|
stderr: "pipe",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]);
|
||||||
|
|
||||||
|
const output = stdout + stderr;
|
||||||
|
expect(output).not.toContain("postgresql");
|
||||||
|
expect(output).toContain("mysql");
|
||||||
|
expect(exitCode).toBe(0);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user